Learn

Redis Extensibility

Simon Prickett
Author
Simon Prickett, Principal Developer Advocate at Redis

How to extend Redis?#

Redis has a Modules API that allows developers to extend its core functionality with new capabilities. Redis Modules are libraries that can be written in C or other languages (including Rust and Zig). Modules can add new commands and/or data structures to Redis. For example, through the addition of modules, Redis can be extended to become a Timeseries or Graph database, while retaining all of its original key/value store functionality.

Modules are loaded into the Redis server at startup by modifying the redis.conf configuration file. Application developers then make use of the extra functionality provided by a module simply by calling the module's commands in the same way they would any other Redis command. We'll see how to do this using the ioredis client for Node.js shortly.

Where to find modules?#

The redis.io website has a catalog of available modules. Redis has developed a number of these that extend Redis in different ways, and we'll use some of them in our sample application.

One way to get started with Redis modules is to use the Redis Stack Docker container from Docker Hub. This is the container that you're using on this course, and it includes all of the following capabilities:

  • Search and Query - a full-featured search and query engine.
  • Time Series - a timeseries database.
  • JSON - adds a native JSON data type to Redis.
  • Probabilistic - adds native Bloom and Cuckoo filter data types to Redis, plus other probabilistic data structures.

Redis offers Redis Cloud, a fully managed service for running and scaling Redis and Redis Stack. Sign up for Redis Cloud and use the full-featured free tier to try it out!

Using Redis Stack in our Application#

Our social checkin application uses three Redis Stack capabilities:

  • We'll use Search and Query to index our user and location Hashes, giving us the ability to perform queries such as:
  • "Which user is associated with the email address [email protected]?"
  • "Find me the users with the most recent checkins".
  • "Find all restaurants within a 3 mile radius of my location that have at least a 3 star rating"
  • JSON adds commands to store and manipulate JSON documents. We'll use those to retrieve extra detail about each of our locations.
  • And finally, we'll take advantage of a space efficient Probabilistic Bloom filter to stop users from posting duplicate checkins.

In the next section, we'll get to grips with Redis JSON...

External Resources#

Check out these links to learn more about which modules are available for Redis and how to use the modules API to create you own: