
Choosing the right Redis data type matters because each structure is optimized for different access patterns and operations. A string might be the best choice for a cached value or counter, while a hash works better for an object, a sorted set for a leaderboard, a stream for event processing, or a vector set for similarity search.
Redis has also expanded considerably in recent releases. Redis Open Source 8 brought data structures such as JSON, time series, and several probabilistic structures into the unified Redis distribution, while newer Redis 8 releases added native vector sets and arrays.
In this guide, we'll explain the most important Redis data types, show the commands commonly used with each one, and help you understand where each data structure fits in modern applications.
What Is Redis?
Redis is an open-source, in-memory data structure server commonly used as a database, cache, message broker, streaming system, and real-time data platform.
Instead of limiting values to a single format, Redis lets each key reference a specialized data structure. Depending on the problem you're solving, that value can be a string, hash, list, set, sorted set, stream, JSON document, time series, vector set, array, geospatial index, or probabilistic structure.
Because Redis primarily operates on data in memory, it can provide very low-latency reads and writes. Its specialized data structures also let applications perform useful operations directly inside Redis instead of retrieving raw data and processing everything in application code.
Some of the key benefits of Redis include:
- Speed: In-memory processing makes Redis suitable for latency-sensitive and real-time workloads.
- Flexible data structures: Developers can choose a structure optimized for the problem instead of treating every value as an undifferentiated blob.
- Atomic operations: Many Redis commands perform updates atomically, which is useful for counters, queues, rankings, and distributed application state.
- Messaging and event processing: Pub/Sub and Redis Streams support real-time communication and event-driven applications.
- AI and search workloads: JSON, search capabilities, and vector sets extend Redis into applications such as semantic search and recommendations.
- Broad use cases: Redis can support caching, session management, rate limiting, leaderboards, analytics, event processing, geospatial search, and more.
Redis Data Types at a Glance
Redis provides both general-purpose and specialized data structures. The best option depends on how your application needs to store, retrieve, update, and query its data.
| Redis Data Type | Best Used For | Common Commands |
|---|---|---|
| Strings | Caching, counters, tokens, simple values | SET, GET, INCR |
| Hashes | Objects and field-value records | HSET, HGET, HGETALL |
| Lists | Queues, stacks, ordered sequences | LPUSH, RPUSH, LPOP, RPOP |
| Sets | Unique values and membership checks | SADD, SISMEMBER, SMEMBERS |
| Sorted Sets | Rankings, leaderboards, scored data | ZADD, ZRANGE, ZSCORE |
| Streams | Event streams and message processing | XADD, XREAD, XREADGROUP |
| JSON | Structured and nested documents | JSON.SET, JSON.GET, JSON.DEL |
| Time Series | Metrics, telemetry, IoT, monitoring | TS.ADD, TS.GET, TS.RANGE |
| Geospatial | Coordinates and nearby-location searches | GEOADD, GEOSEARCH, GEODIST |
| Bitmaps & Bitfields | Compact flags, activity tracking, counters | SETBIT, GETBIT, BITCOUNT, BITFIELD |
| Probabilistic Structures | Approximate counts, frequency, membership, rankings | PFCOUNT, BF.EXISTS, CMS.QUERY |
| Vector Sets | Vector similarity and AI applications | VADD, VSIM, VEMB |
| Arrays | Index-addressable and sparse sequences | ARSET, ARGET, ARGETRANGE |
There isn't one "best" Redis data type. A good Redis data model starts by matching the structure to the access pattern. For example, use hashes when you frequently update individual fields of an object, sorted sets when ranking matters, streams when events must be processed in order, and vector sets when similarity between embeddings matters.
Redis Data Types Explained
Redis supports a growing collection of data structures optimized for different workloads. Let's look at the major Redis data types, the commands used to work with them, and practical situations where each structure is useful.
Redis has a large range of data structures optimized for different uses. Knowing and selecting the appropriate Redis data type helps you build high-performance systems tailored to your application’s needs.
Let’s look at the most commonly used abstract data types in Redis.
String
In Redis, strings are known to be ‘binary safe’. A Redis string represents any data, irrespective of its type. This could be textual data, like a user’s name or email, or binary data like an image or a serialized object. String values can actually store values of different types which makes the string data type quite versatile.
A Redis string can store up to 512 MB of data, and this maximum limit applies individually to both the key and its associated value. Because of these constraints in size and the in-memory nature of Redis, operations on strings are typically fast.
Commands & Their Usage
1. The SET command is used to associate a key with a string value. If the key already exists, this command will overwrite the old value.
plaintextredis-cli SET username “john_doe”Here, the key “username” is set to have the value “john_doe”.
2. The GET command fetches the value associated with a specified key.
plaintextredis-cli GET usernameFor our earlier example, this would return the value “john_doe” associated with the key “username”.
3. The DEL command deletes the value associated with a key.
plaintextredis-cli DEL usernameThis would delete the “john_doe” value set.
Practical Application
Redis strings are versatile and are commonly used for caching web pages or other expensive database queries.
For instance, you can cache the HTML of a user’s profile page in Redis after the first time it’s generated. When another user visits the same profile, you can swiftly fetch the cached HTML from Redis rather than re-rendering the entire page, thus improving speed and reducing server load.
Hash
Redis hashes store collections of field-value pairs under a single Redis key. They are particularly useful for representing objects such as users, products, sessions, configuration records, or other entities with multiple attributes.
For example, instead of storing a user's name, email, and account type as three separate Redis keys, you can keep them together in a hash such as user:1.
Each field within a hash is unique, and individual fields can be read or updated without retrieving the entire object.
Modern Redis versions also support expiration for individual hash fields. Redis 7.4 introduced field-level expiration commands such as HEXPIRE, while Redis 8 added commands such as HGETEX and HSETEX for reading or writing fields while managing their expiration.
Commands & Their Usage
- The
HSETcommand sets one or more fields within a hash.
plaintextredis-cli HSET user:1 name "Alice" email "alice@example.com"This stores the name and email fields inside the user:1 hash.
- The
HGETcommand retrieves a specific field.
plaintextredis-cli HGET user:1 nameThis returns the value associated with the name field.
- The
HGETALLcommand retrieves all fields and values in the hash.
plaintextredis-cli HGETALL user:1This returns the complete set of field-value pairs stored for user:1.
- The
HEXPIREcommand can assign a time-to-live to individual hash fields.
plaintextredis-cli HEXPIRE user:1 3600 FIELDS 1 session_tokenThis allows the session_token field to expire without expiring the entire user:1 hash.
Practical Application
Hashes are useful when an application works with objects whose individual attributes change independently.
A user profile, for example, might contain a name, email address, subscription tier, and last-login timestamp. Redis lets the application update one field without rewriting the entire profile.
Field-level expiration makes hashes even more useful for temporary application state. Session attributes, verification information, recent events, or short-lived metadata can expire independently while permanent fields remain available.
List
Redis Lists are ordered collections of strings. They are unique since they are implemented as linked lists. This means that operations at the beginning or the end of the list, like adding or removing elements, are executed in constant time which makes them extremely fast. This data type is particularly useful when you want to maintain an order of elements like a timeline of activities or a log of events.
Commands & Their Usage
1. The LPUSH command inserts a new value at the start of the list. If the key does not exist, a new list is created.
plaintextredis-cli LPUSH fruits “apple”In this command, “apple” is added to the beginning of the list represented by the key “fruits”.
2. The RPOP command removes and returns the last value of the list. This is useful when you’re using a list as a stack and want to retrieve the most recent addition.
plaintextredis-cli RPOP fruitsThis command will remove and return the value “apple” from the list “fruits”.
Practical Application
Lists are versatile and can be used in different scenarios. One common use is for implementing queues. Jobs or tasks can be “pushed” onto a list and workers can then “pop” tasks from the list for processing. This means that tasks are processed in the order they are received
Another example is a social media timeline where recent activities are added to the start of the list and users view activities from the start to the end of the list.
Set
A Set in Redis is an unordered collection of strings where each string is unique. This means there are no duplicate entries in a Redis set. This unique property of sets makes them useful when you need to track a collection of items without any repetition, like tracking user tags, IP addresses, or even user IDs for unique visitors.
Commands & Their Usage
1. The SADD command is used to add one or multiple values to a set. If a value already exists in the set, it will not be added again, maintaining the uniqueness of values in the set.
plaintextredis-cli SADD tags “music”In this command, the value “music” is added to the set represented by the key “tags”. If “music” already exists in this set, the set remains unchanged.
2. The SMEMBERS command retrieves all the members or values of a set.
plaintextredis-cli SMEMBERS tagsUsing the previous command as a reference, this command fetches all the members of the set “tags”. In our case, it will return “music” among potentially other tags.
3. The SISMEMBER command checks if a value is a member of a set.
plaintextredis-cli SISMEMBER myset "value"This checks if “value” exists in the set “myset”.
4. The SREM command removes the specified member from a set.
plaintextredis-cli SREM myset "value"This removes “value" from the set “myset”.
Practical Application
Sets are ideal when you want to avoid repetition. For instance, if you're building a social media platform where users can add tags to a post, you can use a Redis set to store these tags. This means that even if a user tries to add the same tag multiple times, it will only be stored once.
Another application is in analytics where you want to track unique visitors to a website. Each time a user visits, you can add their user ID or IP address to a Redis set. This way, even if the user visits multiple times, they will be counted only once.
Sorted Sets
Redis sorted sets, also known as Zsets, store unique members together with numeric scores. Unlike regular sets, sorted-set members are automatically ordered by their scores.
This makes sorted sets useful whenever an application needs both uniqueness and ranking. Common examples include gaming leaderboards, priority queues, trending content, scoring systems, and time-based indexes.
Commands & Their Usage
- The
ZADDcommand adds a member and its score to a sorted set.
plaintextredis-cli ZADD leaderboard 100 "player1"This adds player1 to the leaderboard with a score of 100. If the member already exists, its score can be updated.
- The
ZRANGEcommand retrieves members based on their rank.
plaintextredis-cli ZRANGE leaderboard 0 -1 WITHSCORESThis returns all leaderboard members in ascending score order together with their scores.
Modern versions of ZRANGE can also perform score-based queries using the BYSCORE option.
plaintextredis-cli ZRANGE leaderboard 0 100 BYSCORE WITHSCORESThis returns members whose scores fall between 0 and 100.
- The
ZSCOREcommand returns the score associated with a member.
plaintextredis-cli ZSCORE leaderboard "player1"This returns the current score for player1.
- The
ZREMcommand removes a member.
plaintextredis-cli ZREM leaderboard "player1"This removes player1 from the sorted set.
Practical Application
Gaming leaderboards are one of the most common sorted-set use cases. Each player's ID can be stored as a member while their score determines their position.
When a player's score changes, Redis can update it and automatically maintain the ranking. Applications can then retrieve the highest-ranked players or find a specific player's position without sorting the entire dataset themselves.
Sorted sets are also useful for scheduling and time-based indexing when timestamps are used as scores.
Probabilistic Data Structures
Redis supports several probabilistic data structures designed to answer questions about very large datasets without storing or processing every value exactly.
Instead of always providing an exact result, these structures trade a small amount of precision for major improvements in memory efficiency and performance.
Redis supports several probabilistic structures:
| Structure | What It Does | Example Use Case |
|---|---|---|
| HyperLogLog | Estimates the number of unique items | Approximate unique visitors |
| Bloom Filter | Tests whether an item probably exists | Avoiding duplicate processing |
| Cuckoo Filter | Probabilistic membership checking with deletion support | Deduplication systems |
| Count-Min Sketch | Estimates how often items occur | Tracking product or event frequency |
| Top-K | Identifies the most frequent items | Trending products or URLs |
| t-digest | Estimates percentiles | P95 or P99 latency analysis |
HyperLogLog Example
HyperLogLog is useful when you need to estimate the number of unique values in a very large dataset.
The PFADD command adds observations:
plaintextredis-cli PFADD visitors "user1" "user2" "user3"
The PFCOUNT command returns the approximate number of unique values observed:
plaintextredis-cli PFCOUNT visitors
This is useful for estimating metrics such as daily active users or unique website visitors without storing every visitor in a regular Redis set.
Bloom Filter Example
A Bloom filter can efficiently test whether an item has probably been seen before.
plaintextredis-cli BF.ADD processed_orders "order-1001"
You can then check membership:
plaintextredis-cli BF.EXISTS processed_orders "order-1001"
Bloom filters can be useful in deduplication pipelines, crawlers, recommendation systems, and other applications where quickly rejecting values that have definitely not been seen can save significant work.
Count-Min Sketch and Top-K
Count-Min Sketch estimates how frequently individual items occur in a stream, while Top-K helps identify the most frequently occurring items.
These structures can support real-time analytics scenarios such as identifying popular products, frequently accessed pages, heavy network users, or rapidly increasing event types.
Practical Application
Probabilistic structures are most valuable when datasets are large enough that maintaining exact representations becomes expensive.
If exact answers are essential, use conventional Redis structures. If a small approximation error is acceptable and memory efficiency is more important, probabilistic structures can be a better fit.
Bitmaps and Bitfields
Redis bitmaps aren't a separate underlying Redis type. Instead, they provide bit-level operations on Redis strings.
Each bit can represent a binary state such as yes/no, active/inactive, viewed/not viewed, or present/absent. This makes bitmaps extremely memory-efficient when you need to track large numbers of Boolean values.
Commands & Their Usage
The SETBIT command changes a bit at a specific offset:
plaintextredis-cli SETBIT user:1:activity 7 1The GETBIT command retrieves the bit:
plaintextredis-cli GETBIT user:1:activity 7The BITCOUNT command counts the number of bits set to 1:
plaintextredis-cli BITCOUNT user:1:activityRedis also provides the BITFIELD command for treating sections of a string as integers and performing operations such as incrementing counters.
Practical Application
Suppose you want to track whether a user was active on each day of the month. Instead of storing 31 separate values, each day can be represented by one bit.
Bitmaps are useful for activity tracking, feature flags, permissions, analytics, and other situations involving large numbers of binary states.
Geospatial Indexes
Redis geospatial indexes let applications store longitude and latitude coordinates and perform location-based queries.
They are useful for applications that need to find nearby stores, drivers, delivery locations, devices, restaurants, or other geographic points.
Commands & Their Usage
The GEOADD command adds locations:
plaintextredis-cli GEOADD stores -73.9857 40.7484 "store:1"The GEOSEARCH command searches around a coordinate or an existing member:
plaintextredis-cli GEOSEARCH stores FROMLONLAT -73.9857 40.7484 BYRADIUS 5 km WITHDISTThis returns locations within five kilometers of the supplied coordinates.
The GEODIST command calculates the distance between two stored locations:
plaintextredis-cli GEODIST stores "store:1" "store:2" kmPractical Application
A delivery platform could store the current positions of drivers in a Redis geospatial index and search for drivers within a certain radius of a customer.
Other common applications include store locators, proximity search, fleet management, and location-aware applications.
Streams
Redis Streams are designed for storing and processing sequences of events.
A stream behaves like an append-only log: new events are added as entries, each entry receives an ID, and consumers can read events individually or as part of consumer groups.
Streams are particularly useful for event-driven systems because Redis can retain events while multiple consumers process them independently.
Commands & Their Usage
The XADD command adds an event to a stream:
plaintextredis-cli XADD orders * order_id 1001 status createdThe * tells Redis to automatically generate the event ID.
The XRANGE command reads entries from a stream:
plaintextredis-cli XRANGE orders - +This retrieves entries from the beginning to the end of the stream.
Applications can also use XREAD to consume new events:
plaintextredis-cli XREAD COUNT 10 STREAMS orders 0For workloads with multiple workers, Redis supports consumer groups through commands such as XGROUP, XREADGROUP, and XACK.
Practical Application
Streams are useful for event processing, activity feeds, notifications, sensor data, application events, and asynchronous workflows.
For example, an ecommerce application could append every order event to a stream. Separate consumers could then process payment events, update inventory, trigger notifications, or feed downstream analytics systems.
Unlike a simple Redis List used as a queue, Streams provide richer functionality for event IDs, replay, multiple consumers, acknowledgments, and consumer groups.
JSON
Redis supports JSON as a native data structure for storing hierarchical documents.
Instead of serializing an entire JSON object into a Redis string, applications can access and modify specific fields or nested values inside the document.
Redis JSON supports JSONPath expressions, making it possible to target specific parts of complex documents.
Commands & Their Usage
The JSON.SET command stores a JSON document:
plaintextredis-cli JSON.SET user:1 $ '{"name":"Alice","age":32,"plan":"pro"}'The $ represents the root of the JSON document.
The JSON.GET command retrieves the document or a selected path:
plaintextredis-cli JSON.GET user:1 $.nameThe JSON.DEL command removes a selected value or document:
plaintextredis-cli JSON.DEL user:1 $.planPractical Application
JSON is useful when your application works with nested or semi-structured objects that would be cumbersome to break into multiple Redis keys or hash fields.
Examples include user profiles, product catalogs, application configuration, API responses, shopping carts, and documents used by search applications.
Because applications can modify individual JSON paths, they don't always need to retrieve and rewrite the entire document when one field changes.
Time Series
The Redis time-series data type is designed for measurements that change over time.
Each sample contains a timestamp and numeric value, making the structure useful for metrics, IoT readings, financial data, monitoring, telemetry, and real-time analytics.
Redis can also perform operations such as filtering, aggregation, downsampling, and range queries over time-series data.
Commands & Their Usage
The TS.ADD command adds a sample:
plaintextredis-cli TS.ADD temperature:room1 * 22.5Using * tells Redis to use the current timestamp.
The TS.GET command retrieves the most recent sample:
plaintextredis-cli TS.GET temperature:room1The TS.RANGE command retrieves samples within a time range:
plaintextredis-cli TS.RANGE temperature:room1 - +This retrieves all available samples from the earliest to the latest timestamp.
Practical Application
Suppose thousands of IoT devices continuously report temperature, pressure, or battery readings. Time series provides a structure built specifically for storing and querying those measurements over time.
Similar patterns appear in infrastructure monitoring, application performance monitoring, financial markets, industrial systems, and business metrics.
Vector Sets
Vector sets are one of Redis's newer data structures and are designed for vector similarity search.
Instead of associating each member with a numeric score, as a sorted set does, a vector set associates members with multi-dimensional vectors.
Those vectors often represent embeddings generated from text, images, products, users, or other data. Redis can then find the members whose vectors are most similar to a query vector.
Commands & Their Usage
The VADD command adds vectors to a vector set:
plaintextredis-cli VADD points VALUES 2 1.0 1.0 point:AThis creates a two-dimensional vector for point:A.
Another vector can be added using:
plaintextredis-cli VADD points VALUES 2 1.0 0.0 point:BThe VSIM command performs a similarity search:
plaintextredis-cli VSIM points VALUES 2 0.9 0.1Redis returns the members whose vectors are most similar to the supplied query vector.
You can also search using the vector of an existing member:
plaintextredis-cli VSIM points ELE point:A WITHSCORES COUNT 4Practical Application
Vector sets are particularly relevant to modern AI applications.
Embeddings produced by machine-learning models can represent the semantic meaning of text, products, images, users, or other objects. Redis can store these representations and quickly retrieve similar items.
Common use cases include semantic search, recommendations, retrieval for AI applications, similarity matching, and contextual retrieval.
Arrays
Redis 8.8 introduced the Array data structure, expanding Redis's options for ordered and index-addressable data.
Redis arrays are sparse sequences of strings. Unlike Lists, where accessing an arbitrary position can require traversing the structure, Arrays are designed for efficiently working with values when their numeric index is meaningful.
Sparse arrays also allow applications to use widely separated indexes without filling every position in between.
Commands & Their Usage
The ARSET command stores a value at a specific index:
plaintextredis-cli ARSET events 47 "event-47"The ARGET command retrieves the value at an index:
plaintextredis-cli ARGET events 47The ARGETRANGE command retrieves values across a range:
plaintextredis-cli ARGETRANGE events 40 50The ARLEN command returns the logical length of the array:
plaintextredis-cli ARLEN eventsPractical Application
Arrays are useful when the numeric position itself is part of your data model.
For example, an application might associate positions with time buckets, numbered events, slots, lines, or other indexed information.
If your workload frequently needs to access a known position directly, an Array can be a more natural choice than a Redis List.
How to Choose the Right Redis Data Type
The best Redis data type depends primarily on how your application accesses its data.
Use a String for simple values, cached content, tokens, and counters.
Use a Hash when you need to store an object and frequently read or modify individual fields.
Use a List when insertion order matters and most operations happen at either end of the collection.
Use a Set when values must be unique and you need fast membership checks.
Use a Sorted Set when members need both uniqueness and ranking.
Use a Stream when you're storing a sequence of events that consumers may need to process or replay.
Use JSON for hierarchical documents where you need to access or update nested data.
Use Time Series for timestamped measurements and metrics.
Use a Geospatial index for coordinate-based proximity searches.
Use probabilistic structures when approximate answers can dramatically reduce memory requirements.
Use a Vector Set when your application needs vector similarity search for embeddings, recommendations, or AI workloads.
Use an Array when values are naturally addressed by numeric position and efficient indexed access is important.
Matching the data structure to the access pattern keeps Redis models simpler and can reduce the amount of data processing your application has to perform outside Redis.
Power Real-Time Data Workflows With Estuary
Redis is often one part of a much larger data architecture. Operational databases, SaaS applications, analytics platforms, data warehouses, AI systems, and streaming infrastructure may all need access to continuously changing data.
Estuary is a right-time data platform that unifies change data capture (CDC), streaming, and batch data movement in one managed system.
With Estuary, teams can capture data from databases, SaaS applications, APIs, and streaming platforms; transform it while it moves; and deliver it to downstream systems for analytics, operations, and AI.
Some of Estuary's core capabilities include:
- Change Data Capture: Capture inserts, updates, and deletes from supported databases without repeatedly querying entire tables.
- Real-time streaming: Move continuously changing data with low latency when applications require fresh information.
- Batch and right-time delivery: Choose the cadence that fits the workload instead of forcing every pipeline into either pure batch or pure streaming.
- Streaming transformations: Transform data using SQL or TypeScript as part of the pipeline.
- Reusable collections: Capture data once into durable collections that can support multiple downstream workflows and backfills.
- Schema management: Detect and manage schema changes as source data evolves.
- Multiple destinations: Deliver the same captured datasets to systems supporting analytics, operations, and AI workloads.
This approach is especially useful when Redis participates in a broader real-time architecture. Rather than creating independent integration pipelines for every operational, analytics, or AI system, teams can build reusable data flows and control how quickly each destination receives updated data.
Conclusion
Redis has evolved far beyond a basic in-memory key-value store. Its collection of specialized data structures gives developers different tools for caching, object storage, queues, rankings, event processing, analytics, geospatial search, time-series data, JSON documents, and AI-powered similarity search.
Classic structures such as Strings, Hashes, Lists, Sets, and Sorted Sets remain fundamental, but modern Redis applications can also take advantage of Streams, JSON, Time Series, probabilistic structures, Vector Sets, and the Array data structure introduced in Redis 8.8.
The key is choosing a Redis data type based on how your application needs to access and manipulate the data. Doing so can simplify application logic, reduce unnecessary processing, and help you take advantage of operations Redis has already optimized for each structure.
And when Redis is part of a broader data architecture, keeping operational and analytical systems supplied with fresh data becomes just as important as choosing the right Redis structure. Estuary helps teams capture, transform, and deliver data across databases, SaaS applications, streaming systems, warehouses, and other destinations using a unified platform for CDC, streaming, and batch pipelines.
Ready to build dependable data pipelines for analytics, operations, and AI? Try Estuary and start building your first data flow.

About the author
Jeffrey is a data engineering professional with over 15 years of experience, helping early-stage data companies scale by combining technical expertise with growth-focused strategies. His writing shares practical insights on data systems and efficient scaling.











