educative.io

Educative

Why do u use cache?

Index serer will store data in reddis or any other in memory store, so why do we need cache on top of it?As there is a cache it the last of chapter.Why do we need it?

A cache is a reserved storage location that collects temporary data to help websites, browsers, and apps load faster. Whether it’s a computer, laptop or phone, web browser or app, you’ll find some variety of cache. A cache makes it easy to quickly retrieve data, which in turn helps devices run faster.

Here is how I understand it: the cache mentioned in the article is not for the index servers’ data, but for the hot tweets, i.e. tweets DBs data. Its purpose is to store tweets that are accessed often and to decrease the traffic to the tweets’ DBs.
The flow is as follows: a user performs a search, the result of the tweetIDs are retrieved using index servers based on the query; then all the tweets, whose IDs have been returned in the result, need to be retrieved by their IDs. That’s where the cache will be checked for popular tweets’ contents instead of going to the DBs.

2 Likes