6 lesser-known Redis features you should try
Introduction
Redis database is a widely recognized and essential piece of infrastructure, commonly used as a cache and often perceived as just a fast key-value store. However, over the years, it has evolved into a feature-rich data platform, offering much more than just speed.
In 2021, I analyzed Signal Internet Messanger’s server code. It surprised me with interesting use cases of Redis Pub/Sub and Redis Lua interpreter. In this blog post, we'll explore lesser-known but powerful Redis server features that go beyond simple caching.
What is Redis?
Redis is an in-memory database designed for high-speed data storage and retrieval. Unlike traditional databases that rely on disk storage, Redis keeps frequently accessed data in server memory, allowing applications to fetch data almost instantly. This makes it an excellent solution for storing frequently accessed data, such as session information, user preferences, or real-time analytics.
One of the key benefits of Redis is its role in performance optimization. By reducing the need to repeatedly query a slower disk-based database, Redis helps lower server load and ensures that applications remain responsive even under heavy traffic. By efficiently managing frequently requested data, Redis significantly improves application performance, making it a crucial tool for modern web applications, APIs, and microservices.
Redis features
Redis Streams
Redis Streams is a powerful data structure that functions as an append-only log. However, it offers additional capabilities that make it comparable to traditional streaming solutions like Apache Kafka. With Redis Streams, you can query events by range or listen for new items as they appear in real-time. Additionally, it supports consumer groups, enabling multiple consumers to process the stream collaboratively.
Despite these similarities, there are key differences between Redis Streams and Apache Kafka, particularly in how data is partitioned and managed. Redis Streams is designed for lightweight streaming scenarios and does not provide Kafka’s partitioning model, but it remains a powerful alternative for real-time event processing within Redis environments.
In our comparison of message queues performance, we explored Redis Streams' features in-depth and compared them with other streaming solutions. If you’re interested in its performance relative to Apache Kafka, check out the benchmark results to see how it stands against other messaging systems.
JSON Support
In recent years, many databases, including SQL-based ones, have introduced JSON as a supported data type. The key advantage of this capability is the ability to store complex objects in a widely recognized format, making data more flexible and easier to work with.
Redis has taken a similar approach, allowing you to store JSON objects, retrieve nested values, and perform queries using JSONPath. Additionally, Redis supports atomic partial updates, enabling efficient modifications without needing to overwrite entire objects. This makes Redis an excellent choice for applications that require dynamic data structures and real-time updates while maintaining high performance.
Gen AI - vector database
With the recent boom in AI and vector databases, it’s important to know that Redis can also function as a vector database. It enables the storage of vectors with metadata, the definition of secondary indexes, and the performance of vector searches, including k-nearest neighbor (KNN) search. This makes Redis a viable option for AI-driven applications that require fast similarity searches, such as recommendation systems, image recognition, and natural language processing (NLP) tasks.
However, the role of Redis in AI goes beyond vector storage. Redis can be used as a semantic cache, allowing applications to store frequently asked questions in retrieval-augmented generation (RAG) pipelines. Additionally, it plays a crucial role in LLM session storage, helping retain user conversation history for context-aware interactions. In AI-driven applications, choosing the right data structures with low-latency performance is critical, and Redis provides a powerful combination of speed and scalability to handle such demanding workloads.
With its ability to process real-time queries, handle high-throughput AI models, and efficiently manage structured and unstructured data, Redis serves as an excellent choice for building AI-powered applications. Whether for vector similarity search, session storage, or semantic caching, Redis offers the flexibility needed to enhance AI model performance and deliver a seamless user experience.
Time Series
Time series data is often associated with databases such as Prometheus, InfluxDB, ClickHouse, TimeScaleDB, and others. However, Redis also includes support for time series data types! With Redis commands, you can query data by time ranges and perform basic aggregated queries, such as sums, averages, and other statistical calculations.
What makes the Redis time series even more interesting is its integration with popular monitoring and visualization tools. Both Grafana and Telegraf can use Redis as a data source, enabling real-time analytics and monitoring. This allows developers to leverage Redis’s speed and efficiency for time series workloads, making it a viable alternative to dedicated time series databases in certain use cases.
Probabilistic data structures
Probabilistic data structures are one of the lesser-known data types in Redis. Have you ever heard of Bloom filters? They are widely used inside database engines, such as Cassandra, to optimize lookups and reduce storage overhead.
Redis supports not only Bloom filters but also Cuckoo filters, HyperLogLog, and other probabilistic structures. These structures trade-off perfect accuracy for massive memory savings, making them ideal for scenarios where approximate results are acceptable. For example, Bloom filters can definitely confirm that an item is not in a dataset, but can only estimate whether it is present.
A practical use case could be checking whether a discount code has already been used. If you have millions of codes to track, a properly configured Bloom filter can serve as the first line of defense, filtering out invalid requests before they hit the main database. This can lead to significant reductions in compute costs and server load, making applications more efficient.
RDI
Redis Data Integration (RDI) is a feature of Redis Enterprise that leverages Change Data Capture (CDC) mechanisms to synchronize data from traditional databases to a Redis cluster. This allows transferred data to be transformed and filtered, making it easier to fit into Redis data structures.
RDI supports sources such as Oracle, MySQL, PostgreSQL, and others. Its purpose is not just to perform a one-time migration but to enable a continuous synchronization process between these systems. Applications can write data to a traditional database while reading from Redis for faster access, without needing to perform implicit writes to Redis itself.
If your application can tolerate eventual consistency due to the CDC pipeline, RDI can be an effective strategy for reducing database load. It is particularly useful for cache-powered architectures, where Redis serves as a high-speed data layer while keeping the underlying database as the system of record.
Have you heard of Debezium? RDI leverages it underneath. Debezium is an open-source project that enables streaming data from Change Data Capture (CDC) to Apache Kafka or from Kafka to JDBC-compatible databases.
Conclusions
Redis and its forks are widely used in modern systems. While it is commonly recognized for its in-memory storage capabilities, it is worth considering its broader feature set. Beyond caching, Redis can be leveraged for event-driven architectures using Redis Streams. Starting with Redis Streams can provide a quick way to build event-driven features, and as the system scales, transitioning to a fully-fledged Apache Kafka cluster may become a natural step. Since Redis is already part of many infrastructures, utilizing its existing features can accelerate development and deployment without introducing entirely new systems that require additional maintenance.
The Redis team continues to work on new capabilities that influence how applications are designed. One interesting improvement is client-side caching, where additional in-memory data is stored directly on the application side. This approach reduces network latency by eliminating unnecessary round trips, improving application performance with minimal effort.
If you’d like to learn more about Redis project and its data models, I would recommend taking a look at Redis University, where you can find a range of courses covering both basic and advanced Redis features, as well as Redis Cloud.
SoftwareMill is a Redis partner, contact us to get consultation about potential Redis implementation and its features and use cases in your system!
Reviewed by: Michał Ostruszka