One of the most common use cases for Redis is to use it the database as a caching layer for your data, but Redis can do a lot more (I will publish new articles later)!
In this article, you will learn using a straightforward service, how to cache the result on some REST API calls to accelerate the data access, and also reduce the number of calls to external services.
For this example, I am using the “Redis Movie Database” application, a microservice-based application that I created to showcase and explain various features of Redis and Redis Enterprise.
You can see the caching service in action in this video:
Architecture Overview
The application uses a third party API provided by the “OMDb API” to retrieve the ratings of the movie using its IMDb identifier. The frontend application call the /caching/rating/
service to get the rating information from OMDB.
This service is doing the following:
- Check if the rating data is already cached retrieve from the cache
- If the information is not cached, the system calls the OMDB API with the proper key and Movie ID
- The result is cached in Redis with a time to live of 120 seconds
- The ratings are returned to the client.