What are Redis's main data types, and what problem does each one solve?
Short answer
Redis is an in-memory key-value store with built-in data structures: caching, sessions, counters, rate limiting, locks, leaderboards, light queues. Pick the right type and each operation is one O(1) or O(log N) command on the server.
3 points to say:
- Pick the type so the operation is one atomic server-side command, instead of reading the whole object into the app and writing it back.
- Hash for editing single fields, JSON string for reading and writing as a whole; small hashes are stored as a very compact
listpack. - Sorted set = skiplist + hashtable:
ZADD/ZRANKin O(log N), a fit for leaderboards and delay queues.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.