Suggest an editImprove this articleRefine the answer for “What main data types does Redis support?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)Redis supports a set of core data structures: String, List, Set, Sorted Set (a set with a score), Hash, Bitmap, HyperLogLog, Stream, and Geo (geospatial data) - each implemented as efficiently as possible for in-memory work. **Key point:** Redis isn't just a key-value store, it's a set of highly efficient in-memory data structures that can be combined for any scenario, from caching to streaming analytics.Shown above the full answer for quick recall.Answer (EN)ImageRedis supports a **set of core data structures**, each implemented as efficiently as possible for storage and manipulation in RAM. These types are the foundation of everything Redis does. ### 1. String The simplest, most basic data type, **key-value**. It can store text, numbers, JSON, binary data, images, and more. Example: ```bash SET user:name "Alice" GET user:name ``` Arithmetic is supported: ```bash INCR counter DECRBY counter 5 ``` *A quirk:* a string in Redis can be up to **512 MB**. ### 2. List An ordered collection of strings, like a queue or a stack. Elements can be added and removed from either end. Example: ```bash LPUSH queue task1 RPUSH queue task2 LPOP queue ``` *Uses:* task queues, event feeds, chats. ### 3. Set An unordered set of **unique** elements. Supports set-theory operations: intersection, union, difference. Example: ```bash SADD tags "redis" "database" "cache" SMEMBERS tags SISMEMBER tags "redis" ``` *Uses:* storing unique IDs, subscribers, tags. ### 4. Sorted Set Like `Set`, but every element has a **score**, a number that determines the sort order. Example: ```bash ZADD leaderboard 1500 "Alice" 1700 "Bob" ZRANGE leaderboard 0 -1 WITHSCORES ``` *Uses:* rankings, leaderboards, prioritization, top lists. ### 5. Hash Holds a set of *field-value* pairs under a single key. It resembles a mini-object or JSON. Example: ```bash HSET user:100 name "Alice" age 25 HGET user:100 name HGETALL user:100 ``` *Uses:* user profiles, configuration, metadata. ### 6. Bitmap Lets you store and manipulate individual bits of a string. Example: ```bash SETBIT users_online 100 1 GETBIT users_online 100 BITCOUNT users_online ``` *Uses:* activity tracking, online statistics, boolean flags. ### 7. HyperLogLog A structure for the **approximate counting of unique elements** with minimal memory use (~12 KB). Example: ```bash PFADD visitors "user1" "user2" "user3" PFCOUNT visitors ``` *Uses:* counting unique users, IPs, events. ### 8. Stream A log of structured events (like Kafka). Supports message IDs, consumer groups, acknowledgments. Example: ```bash XADD events * user "Alice" action "login" XREADGROUP GROUP g1 c1 COUNT 1 STREAMS events > ``` *Uses:* task queues, events, microservices, logging. ### 9. Geo (geospatial data) Lets you store coordinates and run geo-queries (finding nearby points, distances). Example: ```bash GEOADD shops 30.5 50.4 "ShopA" GEORADIUS shops 30.5 50.4 10 km ``` *Uses:* maps, logistics, tracking, "near me" search. ### Summary | Type | Purpose | Example use | |---|---|---| | String | Strings, numbers, JSON | Cache, tokens, counters | | List | Ordered collections | Queues, feeds | | Set | Unique elements | Subscriptions, tags | | Sorted Set | Prioritized elements | Rankings, leaderboards | | Hash | Objects, dictionaries | Profiles, configs | | Bitmap | Bit-level flags | Online activity | | HyperLogLog | Counting unique items | Analytics | | Stream | Event streams | Queues, logging | | Geo | Geo-coordinates | Distance search | Redis isn't just a key-value store, it's a **set of highly efficient in-memory data structures** that can be combined for any scenario, from caching to streaming analytics.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.