Redis stores data in memory for sub-millisecond reads. Use it as a cache, message queue, session store, rate limiter, and real-time leaderboard — all in one tool.
More Than a Cache
Most developers use Redis for caching. But Redis is a full data structure server with use cases far beyond cache.
What You Get for Free
Data structures:
- Strings — cache values, counters, flags
- Hashes — user profiles, object properties
- Lists — queues, activity feeds, recent items
- Sets — tags, unique visitors, intersections
- Sorted Sets — leaderboards, priority queues, time-series
- Streams — event sourcing, message queues (like Kafka-lite)
- Pub/Sub — real-time messaging between services
Common patterns:
# Cache with TTL
SET user:123 '{"name":"Alice"}' EX 3600
# Rate limiting
INCR api:rate:user:123
EXPIRE api:rate:user:123 60
# Leaderboard
ZADD leaderboard 1500 "player1"
ZADD leaderboard 2000 "player2"
ZRANGE leaderboard 0 9 REV WITHSCORES
# Job queue
LPUSH jobs '{"type":"email","to":"alice@test.com"}'
BRPOP jobs 0 # blocking pop (worker waits)
# Pub/Sub
SUBSCRIBE notifications
PUBLISH notifications 'new-order'
Quick Start
# Docker (recommended)
docker run -d --name redis -p 6379:6379 redis:7-alpine
# Node.js
npm i ioredis
import Redis from 'ioredis';
const redis = new Redis();
await redis.set('key', 'value', 'EX', 3600);
const value = await redis.get('key');
Performance
- 100,000+ operations/second on a single instance
- Sub-millisecond latency for reads and writes
- Persistence options: RDB snapshots, AOF log, or both
- Clustering: shard data across multiple nodes
- Replication: master-replica for high availability
Redis Stack (Free Add-ons)
- RedisJSON — native JSON document storage
- RediSearch — full-text search with secondary indexes
- RedisTimeSeries — time-series data with aggregation
- RedisBloom — probabilistic data structures
If your app makes the same database query twice — Redis between your app and database will make it 100x faster.
Need web scraping or data extraction? Check out my tools on Apify — get structured data from any website in minutes.
Custom solution? Email spinov001@gmail.com — quote in 2 hours.
Top comments (0)