Redis
In one line
Redis is an in-memory key-value database — it stores data as key-value pairs in RAM for sub-millisecond access.
In simple words
Redis (Remote Dictionary Server) is an in-memory key-value store. It keeps all data in RAM, which makes it extremely fast — sub-millisecond reads and writes. The trade-off is that data is volatile (lost on restart) unless you enable persistence.
Redis stores key-value pairs: SET name "Ada" stores the value "Ada" under the key "name", and GET name retrieves it. Beyond simple strings, Redis supports lists, sets, sorted sets, hashes, and more.
Common use cases:
- Caching: store frequently accessed data to avoid hitting the main database.
- Session storage: keep user sessions in Redis for fast access.
- Rate limiting: count requests per user with atomic increments.
- Real-time features: leaderboards, pub/sub messaging, queues.
Redis is not a replacement for your main database — it is a fast companion for specific use cases.
Example
# Set and get a value
redis-cli SET user:1:name "Ada"
redis-cli GET user:1:name # → "Ada"
# Increment a counter (atomic)
redis-cli INCR page:home:views
redis-cli INCR page:home:views
redis-cli GET page:home:views # → "2"Redis stores key-value pairs in memory. INCR atomically increments a counter.
Related terms
Related Resources
Related Lessons
- Redis Basics
Learn Redis fundamentals.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.