Reputation: 10520
I'm working on a web app that gets data from an API provider. It's getting the data I need but I need a way to cache this data to keep from calling them again for the same data.
Then I stumbled on Redis which seems to serve my purpose but I'm not 100% clear about the concept of caching using Redis. I've checked their documentation but I don't really follow what they have to say.
Let's suppose I have just deployed my website to live and I have my first visitor called A. Since A is the first person that visits, my website will request a new set of data over API provider and after a couple seconds, the page will be loaded with the data that A wanted.
My website caches this data to Redis to serve future visitors that will hit the same page.
Now I have my second visitor B.
B hits the same page url as A did and because my website has this data stored in the cache, B is served from the cache and will experience much faster loading time than what A has experienced.
Is my understanding in line with with the concept of web caching?
I always thought of caching as per user basis so my interaction on a website has no influence or whatsoever to other people but Redis seems to work per application basis.
Upvotes: 0
Views: 345
Reputation: 59
Its based on the requirements.
I will give a brief overview of how Redis works. Redis contains key value pairs. Say, if you want to cache an user's profile details, you can do it in the following way
Key - profile_user
Value - ["x", "23"]
So, the naming of key is all matters here.
You can have different keys for web level caching and user level caching. Application should be able to generate appropriate keys to fetch same data from Redis.
I hope I have made it clear.
Upvotes: 1