Lazy loading

Instead of writing everything into the cache, we can perform lazy loading, which is essentially caching all the responses from the database to the cache. Our application, starting from scratch, will always have a cache miss, but as soon as reads to the database are performed from the server, they are cached for other nodes to be able to get that same result. This approach might mean a high cache miss rate in the beginning, but we are able to store results from complex queries and the cache consumption is not as high as with the write-through approach. It is a bit heavier in the beginning but it makes up for it in the long run, especially if we need to cache frequent very heavy transaction responses from the database. To make sure the responses do not become stale, we can implement custom TTL values that help us expire the data in the cache after a certain time, and thus the lazy loading will start over for all the cached responses that expire, making sure we are getting fresh data into our application. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset