Skip to content

You are viewing a free preview of this lesson.

Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.

What is Redis?

What is Redis?

Redis is an open-source, in-memory data structure store that serves as a database, cache, message broker, and streaming engine. The name stands for Remote Dictionary Server, and it has become one of the most popular databases in the world thanks to its exceptional speed and versatility.

In-Memory Architecture

The defining characteristic of Redis is that it holds all data in RAM. Disk-based databases must read data from storage for every query, which introduces latency in the millisecond range. Redis responds to most commands in under a millisecond because data is already in memory. This makes Redis orders of magnitude faster than traditional relational or document databases for read-heavy workloads.

What Redis Stores

Unlike databases that store only rows and columns or JSON documents, Redis supports a rich set of native data structures:

  • Strings — the simplest key-value pairs; values can be text, integers, or binary data
  • Hashes — field-value maps, like a row in a table
  • Lists — ordered sequences of strings, supporting push and pop from both ends
  • Sets — unordered collections of unique strings
  • Sorted Sets — sets where each member has a score used for ordering
  • Streams — append-only logs for event sourcing and messaging
  • Bitmaps and HyperLogLog — space-efficient probabilistic structures

Common Use Cases

# Redis excels in these scenarios:
# 1. Caching — store expensive query results
# 2. Session storage — keep user sessions in memory
# 3. Rate limiting — count requests per user per minute
# 4. Leaderboards — sorted sets rank players by score
# 5. Pub/Sub messaging — broadcast events between services
# 6. Job queues — lists act as efficient FIFO queues

Single-Threaded Event Loop

Redis processes commands using a single-threaded event loop. This design eliminates lock contention and context switching, contributing to its predictable low-latency performance. Modern Redis versions use I/O threads for network operations while keeping command execution single-threaded.

Redis vs a Traditional Cache

Many developers first encounter Redis as a cache layer in front of a PostgreSQL or MySQL database. However, Redis is a fully featured primary database for the right workloads. Its optional persistence features (RDB snapshots and AOF logging) allow it to survive restarts without losing data, blurring the line between a cache and a durable store.

Who Uses Redis

Redis is deployed by Twitter, GitHub, Stack Overflow, Pinterest, Snapchat, and thousands of other companies. It is available as a managed service on AWS (ElastiCache), Google Cloud (Memorystore), and Azure (Azure Cache for Redis), making it easy to operate at scale without managing infrastructure.

Understanding what Redis is — and when to reach for it — is the first step toward building faster, more scalable applications.