When performing caching, there are several ways to control the behavior of our cache system depending on our requirements. These are called caching strategies, and we can put different caching strategies to work when we have different data requirements.
So, let's see how caching can be implemented to offload a database. Any time we are implementing a caching solution, we treat the cache as a separate data store that can hold some or all of the data being used in our application. The first read request will thus always be directed towards the cache, and the cache will either respond with a piece of data that it has – a so called cache hit - or it will not have the data and that would be a cache miss. When the data is not in the cache, there are several more steps that need to be undertaken. First, we need to direct the read at the database and request...