Estuary

Redis Data Types: Complete Guide to Commands & Use Cases (2026)

In this guide, discover the key Redis data types and learn about the various commands and data structures to optimize your Redis database.

Redis Data Types - Data Types
Share this article

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 Data Types - 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 TypeBest Used ForCommon Commands
StringsCaching, counters, tokens, simple valuesSET, GET, INCR
HashesObjects and field-value recordsHSET, HGET, HGETALL
ListsQueues, stacks, ordered sequencesLPUSH, RPUSH, LPOP, RPOP
SetsUnique values and membership checksSADD, SISMEMBER, SMEMBERS
Sorted SetsRankings, leaderboards, scored dataZADD, ZRANGE, ZSCORE
StreamsEvent streams and message processingXADD, XREAD, XREADGROUP
JSONStructured and nested documentsJSON.SET, JSON.GET, JSON.DEL
Time SeriesMetrics, telemetry, IoT, monitoringTS.ADD, TS.GET, TS.RANGE
GeospatialCoordinates and nearby-location searchesGEOADD, GEOSEARCH, GEODIST
Bitmaps & BitfieldsCompact flags, activity tracking, countersSETBIT, GETBIT, BITCOUNT, BITFIELD
Probabilistic StructuresApproximate counts, frequency, membership, rankingsPFCOUNT, BF.EXISTS, CMS.QUERY
Vector SetsVector similarity and AI applicationsVADD, VSIM, VEMB
ArraysIndex-addressable and sparse sequencesARSET, 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 Data Types - Data Types
Image Source

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

Redis Data Types - Strings

Image Source

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.

plaintext
redis-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.

plaintext
redis-cli GET username

For 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.

plaintext
redis-cli DEL username

This 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 Data Types - Hash

Image Source

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

  1. The HSET command sets one or more fields within a hash.
plaintext
redis-cli HSET user:1 name "Alice" email "alice@example.com"

This stores the name and email fields inside the user:1 hash.

  1. The HGET command retrieves a specific field.
plaintext
redis-cli HGET user:1 name

This returns the value associated with the name field.

  1. The HGETALL command retrieves all fields and values in the hash.
plaintext
redis-cli HGETALL user:1

This returns the complete set of field-value pairs stored for user:1.

  1. The HEXPIRE command can assign a time-to-live to individual hash fields.
plaintext
redis-cli HEXPIRE user:1 3600 FIELDS 1 session_token

This 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.

plaintext
redis-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.

plaintext
redis-cli RPOP fruits

This 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

Redis Data Types - Set

Image Source

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.

plaintext
redis-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.

plaintext
redis-cli SMEMBERS tags

Using 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.

plaintext
redis-cli SISMEMBER myset "value"

This checks if “value” exists in the set “myset”.

4. The SREM command removes the specified member from a set.

plaintext
redis-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 Data Types - Sorted set

Image Source

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

  1. The ZADD command adds a member and its score to a sorted set.
plaintext
redis-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.

  1. The ZRANGE command retrieves members based on their rank.
plaintext
redis-cli ZRANGE leaderboard 0 -1 WITHSCORES

This 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.

plaintext
redis-cli ZRANGE leaderboard 0 100 BYSCORE WITHSCORES

This returns members whose scores fall between 0 and 100.

  1. The ZSCORE command returns the score associated with a member.
plaintext
redis-cli ZSCORE leaderboard "player1"

This returns the current score for player1.

  1. The ZREM command removes a member.
plaintext
redis-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 Data Types - HyperLogLog

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:

StructureWhat It DoesExample Use Case
HyperLogLogEstimates the number of unique itemsApproximate unique visitors
Bloom FilterTests whether an item probably existsAvoiding duplicate processing
Cuckoo FilterProbabilistic membership checking with deletion supportDeduplication systems
Count-Min SketchEstimates how often items occurTracking product or event frequency
Top-KIdentifies the most frequent itemsTrending products or URLs
t-digestEstimates percentilesP95 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:

plaintext
redis-cli PFADD visitors "user1" "user2" "user3"

The PFCOUNT command returns the approximate number of unique values observed:

plaintext
redis-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.

plaintext
redis-cli BF.ADD processed_orders "order-1001"

You can then check membership:

plaintext
redis-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:

plaintext
redis-cli SETBIT user:1:activity 7 1

The GETBIT command retrieves the bit:

plaintext
redis-cli GETBIT user:1:activity 7

The BITCOUNT command counts the number of bits set to 1:

plaintext
redis-cli BITCOUNT user:1:activity

Redis 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:

plaintext
redis-cli GEOADD stores -73.9857 40.7484 "store:1"

The GEOSEARCH command searches around a coordinate or an existing member:

plaintext
redis-cli GEOSEARCH stores FROMLONLAT -73.9857 40.7484 BYRADIUS 5 km WITHDIST

This returns locations within five kilometers of the supplied coordinates.

The GEODIST command calculates the distance between two stored locations:

plaintext
redis-cli GEODIST stores "store:1" "store:2" km

Practical 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:

plaintext
redis-cli XADD orders * order_id 1001 status created

The * tells Redis to automatically generate the event ID.

The XRANGE command reads entries from a stream:

plaintext
redis-cli XRANGE orders - +

This retrieves entries from the beginning to the end of the stream.

Applications can also use XREAD to consume new events:

plaintext
redis-cli XREAD COUNT 10 STREAMS orders 0

For 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:

plaintext
redis-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:

plaintext
redis-cli JSON.GET user:1 $.name

The JSON.DEL command removes a selected value or document:

plaintext
redis-cli JSON.DEL user:1 $.plan

Practical 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:

plaintext
redis-cli TS.ADD temperature:room1 * 22.5

Using * tells Redis to use the current timestamp.

The TS.GET command retrieves the most recent sample:

plaintext
redis-cli TS.GET temperature:room1

The TS.RANGE command retrieves samples within a time range:

plaintext
redis-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:

plaintext
redis-cli VADD points VALUES 2 1.0 1.0 point:A

This creates a two-dimensional vector for point:A.

Another vector can be added using:

plaintext
redis-cli VADD points VALUES 2 1.0 0.0 point:B

The VSIM command performs a similarity search:

plaintext
redis-cli VSIM points VALUES 2 0.9 0.1

Redis returns the members whose vectors are most similar to the supplied query vector.

You can also search using the vector of an existing member:

plaintext
redis-cli VSIM points ELE point:A WITHSCORES COUNT 4

Practical 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:

plaintext
redis-cli ARSET events 47 "event-47"

The ARGET command retrieves the value at an index:

plaintext
redis-cli ARGET events 47

The ARGETRANGE command retrieves values across a range:

plaintext
redis-cli ARGETRANGE events 40 50

The ARLEN command returns the logical length of the array:

plaintext
redis-cli ARLEN events

Practical 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.

Start streaming your data for free

Build a Pipeline

About the author

Picture of Jeffrey Richman
Jeffrey RichmanData Engineering & Growth Specialist

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.

Streaming Pipelines.
Simple to Deploy.
Simply Priced.
$0.50/GB of data moved + $.14/connector/hour;
50% less than competing ETL/ELT solutions;
<100ms latency on streaming sinks/sources.