Redis is an in-memory data structure store. It excels at caching, session storage, rate limiting, pub/sub, and leaderboards. Key data structures: Strings (SET/GET with TTL), Hashes (HSET/HGETALL for objects), Lists (LPUSH/RPOP for queues), Sorted Sets (ZADD/ZRANGE for leaderboards), Streams (XADD/XREAD for event logs). All commands are atomic. Lua scripts run atomically. Redlock is the distributed mutual-exclusion algorithm across multiple Redis nodes.
Sliding window rate limiter using Sorted Sets.
KEYS * scans all keys — O(N) and blocks the single-threaded Redis during scan. Use SCAN 0 MATCH pattern COUNT 100 with cursor iteration instead.
PUBLISH/SUBSCRIBE loses messages if no subscriber is connected. Use Streams (XADD/XREADGROUP) for durable, acknowledged, consumer-group-based messaging.
Cache keys without TTL grow forever until eviction policy kicks in. Set EX at write time. Monitor memory with INFO memory and keyspace.
Sign in to share your feedback and join the discussion.