educative.io

Educative

Cache memory Size calculation incorrect?

Cache size calculation is based on 5mm read request. However, based on description we are trying to cache 20% of paste - which is 20% of write. hence calculation for cache size should be .2* 1 million*10kb. This will ensure that 20% of bin remains in cache. am i incorrect to assume “writes” to use for cache size calculation ?

2 Likes

I had the same thought. I’d use “writes” for cache size calculation.

1 Like

Cache will be used for the ‘read’ requests. Whenever user tries to access a ‘paste’, we will see if it is in the cache, if not, we will fetch it from database, return to user and put it in cache. So cache is always used to make the ‘reads’ faster.

A lot of times, whenever a user ‘writes’ a new data, it gets cached too, as it is expected that the latest written data has a lot of probability to be read soon.

Hope this clarifies your question.