Redis Demo

This app demonstrates the four most common Redis patterns. Each page shows you what Redis command is being used and why.

๐Ÿ“ฆ Caching

Simulate an expensive database query (2s delay). The first call hits the DB; subsequent calls are served from Redis in <1ms.

SET key value EX 30   โ† store with 30s expiry
GET key               โ† retrieve (or nil if expired)

๐Ÿ”ข Counter / Atomic Increments

Track page visits, likes, or inventory counts atomically โ€” no race conditions, no locks.

INCR visits           โ† atomically increment by 1
INCRBY stock -5       โ† decrement by 5

๐Ÿšฆ Rate Limiting

Allow a user N requests per minute. Redis TTL automatically resets the window.

INCR user:ip:requests
EXPIRE key 60         โ† auto-reset after 60 seconds

๐Ÿ† Leaderboard

Sorted Sets store members with a score. Redis keeps them sorted automatically โ€” perfect for rankings.

ZADD leaderboard 1500 "alice"   โ† add/update score
ZREVRANGE leaderboard 0 9       โ† top 10 (highest first)
ZSCORE leaderboard "alice"      โ† get one player's score

๐Ÿ”‘ Inspect All Redis Keys

See every key currently stored in Redis with its type and TTL.