0

I am really confused about this. I want to understand what is the difference between caching of data and loading data from database tables on server or application startup? Please guide me.

AkashSharma
  • 107
  • 1
  • 2
  • 13

1 Answers1

0

Two are very different things .

Caching is better explained here

Caching is a way in which response time of your web service can be optimised when you see a pattern in your coming requests by storing it in database like Redis.

Loading of database tables in memory on startup of web service is done to ensure that there should not be any need to make any database query .

Because reading data from memory is always faster than making a native database query.

Question is : How would you use both?

Lets say you have some database tables which have some data which is required to help you serve via your web service at realtime.

So, you first dump your whole data from database tables with the help of a cron job[offline].

And at realtime, your web service fetches from redis for any data.(Advantage - No need to make database queries at realtime for tables on startup). Just Fetch from redis for whatever you need.

Moreover, you can cache your incoming requests into redis at realtime, so next time the request comes, see if present in redis and then return from cache(otherwise cache the new request.)

Advantage - Your web service response time becomes faster.

Vivek Bansal
  • 216
  • 2
  • 8