Intro to Redis — with Docker Compose
What is Redis?
Redis is a high throughput, in-memory key-value store used for fast lookup. It supports common data structures such as strings, lists, sets, hashes, and more (redislabs). Since Redis stores data in-memory, it does not face the same read/write (I/O) limitations and performance issues that databases face with hard disks. Although Redis stores and accesses data in-memory, it can be persisted on the hard disk for resilience; Docker Volumes makes this process easy.
When would we use Redis?
Redis is commonly used in web stacks as the “cache” service accessed by the API. For example, the client (browser) will make a request to the API (server) for some common piece of data, like “Top 10 Product Categories”. Rather than the API going directly to the database, executing a potentially long running query statement (depending on how well your database schema is structured) and awaiting the result, we can populate both the Redis key-value store and the database with identical information.
In this scenario, the database is used as the “true data source” and Redis is used as the lightweight, fast lookup for commonly accessed data — like Top Categories. If the client requested all information about a particular, unpopular Product ID, for instance, we probably should not store all…