Suggest an editImprove this articleRefine the answer for “What does the "key-value" model mean in the context of Redis?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)The "key-value" model means that all data in Redis is stored as "key - value" pairs: the key is a unique name (a string) that gives instant access to the data, and the value is data of any supported type (String, List, Set, Hash, ZSet, Stream, and more). **Key point:** unlike simple key-value systems like Memcached, in Redis the "value" can be a full data structure rather than just a string, which gives O(1) access by key and flexibility of types under a single interface.Shown above the full answer for quick recall.Answer (EN)ImageThe **"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: ```javascript key → value ``` ### The 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 ```bash SET user:1 "Anna" GET user:1 ``` Here: - 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 ```bash 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.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.