Engineering in practice
Redis beyond the cache
13 October 2026 · 7 min read
Beyond the “60-Second TTL Cache” Box
If your engineering team only uses Redis as a glorified key-value dictionary with SET key value EX 60, you are using less than 10% of what Redis has to offer.
In production systems, Redis is often the synchronization backbone of the entire distributed architecture. Its atomic primitives, sorted sets, reliable lists, and pub/sub channels provide elegant solutions to complex distributed coordination problems that would otherwise require heavy brokers or complex database locks.
1. Reliable Distributed Queues via BLMOVE
Most basic Redis queues use RPOP or BRPOP. But if a worker crashes or encounters an out-of-memory error after popping a job, that job is erased forever.
With Redis 6.2+, BLMOVE (and its non-blocking variant LMOVE) provides atomic queue leasing:
BLMOVE pending_jobs in_flight_jobs LEFT RIGHT 5
In a single atomic step, the job is popped from pending_jobs and pushed to in_flight_jobs. If the worker container crashes, the message remains safely in in_flight_jobs. A lightweight watchdog reaper process can inspect in-flight task leases and re-queue stuck jobs:
# Worker execution loop
while running:
job_id = await redis.blmove("jobs:pending", "jobs:processing", timeout=5)
if not job_id:
continue
try:
await process_job(job_id)
# Atomic acknowledge: remove from in-flight on success
await redis.lrem("jobs:processing", 1, job_id)
except Exception:
await handle_retry_or_dead_letter(job_id)
2. Priority and Time-Based Scheduling with Sorted Sets (ZSET)
Sorted Sets (ZSET) score elements numerically, keeping them indexed in logarithmic $O(\log N)$ time. This structure is ideal for:
- Delayed Job Scheduling: Score elements with a UNIX epoch timestamp representing when the job should execute (
enqueue_at). A worker polls the set withZRANGEBYSCORE queue:delayed -inf <current_time>to extract ready jobs. - Dead-Letter Queues (DLQ): Failed tasks can be sorted by expiration or failure count, making triage and inspection trivial.
- Leaderboards and Real-Time Counters: High-frequency metrics can be aggregated and queried with millisecond latencies.
3. High-Throughput Network Pipelining
When querying or setting multiple keys in an async web service, executing individual network roundtrips severely degrades performance.
Instead of:
# Triggers 50 distinct network round-trips across TCP sockets
results = [await redis.get(k) for k in keys]
Use a Redis Pipeline:
async with redis.pipeline(transaction=False) as pipe:
for k in keys:
pipe.get(k)
results = await pipe.execute()
Pipelining packs all 50 operations into a single network packet, executing them sequentially within Redis memory and returning the batch response in one roundtrip.
Summary of Redis Primitives
| Redis Primitive | Real-World Production Application |
|---|---|
SET NX PX | Distributed mutexes with automatic timeout safety |
BLMOVE / LMOVE | Reliable at-least-once message queues with crash recovery |
ZSET (Sorted Set) | Sliding-window rate limiters, delayed tasks, and DLQs |
Pipeline | Batch bulk operations with minimal network socket overhead |
Pub/Sub & Streams | Multi-tenant live event broadcasting and log streaming |