Implementing data caching
In the previous section, we implemented the logic for storing our service data, including movie metadata and movie ratings, in a persistent database. Now, consider the scenario where we never update movie metadata once we save it to the database. In fact, this might be the case in a real movie metadata application since the movie metadata, such as its title or description, would hardly change at all unless we make small corrections to it. Let’s also imagine that our movie metadata service becomes popular, and we start receiving lots of requests to it for movie details. If we start sending millions of requests to our database, it can easily get overloaded and stop responding to our requests at all. How would we solve such a load problem?
There is a powerful technique called data caching that can be helpful in reducing the load on our database. In essence, data caching is a technique of storing a copy or a part of our persistent data in the memory...