Tutorial
What is Redis?: An Overview
February 25, 20267 minute read
Redis is an open-source, in-memory data structure store that can be used as a database, cache, message broker, and streaming engine. It belongs to the class of NoSQL databases known as key/value stores, where unique keys map to values of various data types. Redis is widely adopted for its sub-millisecond response times, rich data structures, and versatility across use cases from caching to real-time analytics.
Prerequisites: No prior Redis experience is needed. This overview is designed for beginners who want to understand what Redis is and why developers choose it.
#How does Redis work?
At its core, Redis stores data as key/value pairs. Keys are unique identifiers, and values can be one of many supported data types. Each data type has its own set of commands for reading and writing data.
For example, you can store a name in a Redis String and associate it with the key "myname" using the SET command, then retrieve it using GET:
Keys in a Redis database are distributed in a flat keyspace. Redis does not enforce a schema or naming policy for keys, giving developers full flexibility over how to organize their data.
#What are Redis data types?
Redis goes far beyond simple key/value string storage. It supports a rich set of data types, each optimized for specific access patterns:
| Data type | Description | Example use |
|---|---|---|
| Strings | The simplest type; stores text, numbers, or binary data up to 512 MB | Counters, cached values, session tokens |
| Lists | Ordered collections of strings (linked lists) | Activity feeds, message queues |
| Sets | Unordered collections of unique strings | Tags, unique visitors, set operations |
| Hashes | Maps of field-value pairs, similar to objects | User profiles, product details |
| Sorted Sets | Sets ordered by a numeric score | Leaderboards, priority queues, rate limiters |
| Streams | Append-only log data structures | Event sourcing, activity logs |
| JSON | Native JSON document storage and querying | Complex nested data, API response caching |
Redis also supports specialized types like Bitmaps, Bitfields, HyperLogLog, and Geospatial indexes for advanced use cases.
#What is Redis used for?
Redis is used across industries wherever fast data access matters. Common use cases include:
- Caching: Store frequently accessed data in memory to reduce database load and speed up response times.
- Session management: Maintain user session data across distributed web applications with built-in expiration.
- Leaderboards and ranking: Use Sorted Sets to build real-time leaderboards with automatic ordering by score.
- Real-time analytics: Track metrics, counts, and time-series data with sub-millisecond writes.
- Pub/Sub messaging: Broadcast messages to multiple subscribers for real-time notifications and chat systems.
- Rate limiting: Control API usage and prevent abuse using counters with expiration.
- Queues and background jobs: Use Lists or Streams as lightweight, high-performance task queues.
#Is Redis a NoSQL database?
Yes, Redis is a NoSQL database. Unlike relational databases that store data in tables with rigid schemas, Redis uses flexible key/value pairs with typed data structures. This makes Redis well suited for use cases where speed, flexibility, and horizontal scalability matter more than complex relational queries.
Redis differs from other NoSQL databases like MongoDB or Cassandra in that it primarily operates in-memory, making it significantly faster for read and write operations.
#How fast is Redis?
Redis is one of the fastest databases available. Because it stores and serves all data from RAM rather than disk, typical operations complete in under one millisecond. Redis can handle hundreds of thousands of operations per second on modest hardware, and millions of operations per second on optimized configurations.
This speed makes Redis an excellent choice for applications that require real-time data access, such as gaming leaderboards, financial trading platforms, and ad-tech bidding systems.
#How does Redis persist data?
While Redis stores data in memory for speed, it provides multiple persistence options to ensure durability:
- RDB (Redis Database): Takes point-in-time snapshots of your data at configured intervals.
- AOF (Append Only File): Logs every write operation, providing stronger durability guarantees.
- RDB + AOF: Combines both methods for a balance of performance and data safety.
This means your data is durable even though all reads are served from an in-memory copy, giving you both speed and reliability.
#Redis vs Memcached
Both Redis and Memcached are popular in-memory stores, but Redis offers several advantages:
- Rich data structures beyond simple strings (Lists, Sets, Hashes, Sorted Sets, Streams, JSON)
- Built-in persistence so data survives restarts
- Pub/Sub messaging for real-time communication
- Lua scripting for server-side logic
- Cluster mode for horizontal scaling with automatic sharding
Memcached is simpler and may be sufficient for basic string caching, but Redis is the more versatile choice for most applications.
#How do I get started with Redis?
The fastest way to start using Redis:
-
Try Redis Cloud free: Sign up for a free Redis Cloud account — no installation required.
-
Run Redis locally with Docker:
-
Follow the quick-start tutorial: Walk through the Redis quick start guide to learn basic commands and data types hands-on.
#Next steps
Ready to dive deeper? Explore these tutorials and resources:
- Quick start guide — set up Redis and learn the basic commands.
- Quick start cheat sheet — a handy reference for common Redis commands.
- Get started with Redis course — a free, comprehensive course at Redis University covering data structures and real-world applications.
- Redis Cloud — a fully managed cloud database with a free tier.
