Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to cache when 99.9% of your data changes frequently?

Okay I know I asked about this before, and the answer was basically cache data that doesn't change often.

Well what does one do when at least 99.9% of the data changes?

In my project the only tables that doesn't get updated or won't get updated frequently would be the member profile info (name/address, and settings)

So how does one still enable some kind of caching but keep and make sure the data being viewed is updated when changes are applied?

like image 327
dswatik Avatar asked Oct 23 '08 08:10

dswatik


People also ask

What data should I cache?

General Cache Use Cases In-memory data lookup: If you have a mobile / web app front end you might want to cache some information like user profile, some historical / static data, or some api response according to your use cases. Caching will help in storing such data.

Which caching strategy should be used if the website frequently needs updated data?

Write-through. In a write-through cache, the cache is updated in real time when the database is updated.

What is the best caching strategy that ensures that data is always fresh?

Write-through ensures that data is always fresh, but can fail with empty nodes and can populate the cache with superfluous data.


1 Answers

I guess, it's not really 99.9% of all data that changes, but it's in 99.9% of all data locations that changes happen.

For example, if you are running a bulletin board, that means that there will be a steady stream of new posts, but old posts will remain the same, and even old threads will stay unchanged for a long, long time.

In that case, you'll need a way to invalidate old cached data, so that you can build a cache as soon as a thread (in the example) is viewed. If there is a change to ONE of these threads (i.e. when someone adds a new post), this one cached item is deleted/marked outdated, so the next time it is viewed, it will be rebuilt. Other items that still haven't changed will use the cache, though.

like image 105
BlaM Avatar answered Oct 13 '22 00:10

BlaM