What does the "key-value" model mean in the context of Redis?
The "key-value" model in the context of Redis means that all data is stored as "key - value" pairs. Every record in Redis has two parts:
key → valueThe essence of the model
Redis doesn't store rows in tables, the way SQL databases do. It's essentially a huge associative array (a dictionary), where:
- the key is a unique name (a string) that gives instant access to the data;
- the value is data of any supported type (String, List, Set, Hash, ZSet, Stream, and more).
Example
SET user:1 "Anna"
GET user:1Here:
- the key is
user:1, - the value is
"Anna".
Redis finds the value by key instantly, like a dictionary in memory.
An example with other types
HSET user:1 name "Anna" age "27"
LPUSH messages "hi" "hello" "bye"
ZADD scores 100 "Anna" 120 "Ivan"All three records are key → value pairs, but the value in each has its own data type:
user:1, a hash (Hash),messages, a list (List),scores, a sorted set (Sorted Set).
Why Redis is "key-value" and not just "key-string"
Although Redis is based on the key-value model, its "value" can be a data structure, not just a string. That's what sets Redis apart from simple key-value systems like Memcached.
Advantages of the model
- O(1) access to data by key (very fast).
- A simple architecture, no tables, indexes, schemas.
- Flexibility: different value types under a single "key → value" interface.
- Scalability: keys can be easily distributed across a cluster.
Uses
- Caching (key = a request, value = the result).
- User sessions.
- Counters and tokens.
- Queues, temporary storage, rankings, and more.
So, the key-value model in Redis is the foundation everything is built on: unique keys, tied to values of any type, processed directly in RAM.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.