Skip to main content
Redis supports a rich set of data types beyond simple key-value pairs. Each data type is optimized for specific use cases and operations.

Core Data Types

Redis provides several fundamental data types, each with its own set of commands and characteristics:

Strings

Binary-safe strings up to 512MB. Used for caching, counters, and distributed locks.

Lists

Ordered collections of strings. Perfect for queues, activity feeds, and stacks.

Sets

Unordered collections of unique strings. Ideal for tags, unique visitors, and relationships.

Sorted Sets

Sets ordered by score. Essential for leaderboards, priority queues, and time series.

Hashes

Field-value maps. Great for objects, user profiles, and counters.

Streams

Append-only log structure with consumer groups. Built for event sourcing and messaging.

Extended Data Types

JSON

Native JSON documents with JSONPath queries. Requires BUILD_WITH_MODULES=yes.

Bitmaps

Bit-level operations on strings. Efficient for analytics and permissions.

HyperLogLog

Probabilistic cardinality estimation. Count unique items with minimal memory.

Geospatial

Longitude/latitude coordinates with radius queries. Built on sorted sets.

Choosing the Right Data Type

Use CaseRecommended TypeWhy
CachingStringsSimple get/set with TTL
Session storageHashes or JSONStructured data with field updates
CountersStringsAtomic INCR/DECR operations
Rate limitingSorted SetsTime-based windowing
LeaderboardsSorted SetsScore-based ranking
QueuesLists or StreamsFIFO/LIFO with blocking
Real-time feedsLists or StreamsChronological ordering
Unique visitorsSets or HyperLogLogUniqueness tracking
TaggingSetsSet operations (union, intersection)
Event sourcingStreamsAppend-only with consumer groups
User profilesHashesObject representation
Location searchGeospatialRadius and proximity queries

Data Type Internals

Redis uses different internal encodings based on data size and type:

Memory-Efficient Encodings

  • LISTPACK: Compact serialization for small collections (lists, hashes, sorted sets)
  • INTSET: Space-efficient integer sets when all members are integers
  • ZIPLIST: Legacy compact encoding (deprecated in favor of listpack)

Standard Encodings

  • HASHTABLE: Standard hash table for larger datasets
  • SKIPLIST: Probabilistic balanced tree for sorted sets
  • QUICKLIST: List of listpacks for efficient list operations
  • RADIX TREE: Efficient tree structure for streams
Redis automatically selects the most efficient encoding based on the data size and configured thresholds. You can view the encoding with the OBJECT ENCODING key command.

Performance Characteristics

Each data type has different performance characteristics:
Data TypeReadWriteRange QueryMemory
StringsO(1)O(1)N/AHighest
ListsO(1) ends, O(N) middleO(1) endsO(N)Medium
SetsO(1)O(1)N/AMedium
Sorted SetsO(log N)O(log N)O(log N + M)High
HashesO(1) fieldO(1) fieldO(N)Medium
StreamsO(1) appendO(1)O(N)Medium-High
For best performance, choose the simplest data type that meets your needs. More complex types like sorted sets have higher overhead.

Module Data Types

These require compiling Redis with BUILD_WITH_MODULES=yes:
  • JSON: Full-featured JSON document storage
  • Time Series: Optimized time-series data with automatic downsampling
  • Bloom Filter: Probabilistic set membership
  • Cuckoo Filter: Bloom filter with deletion support
  • Vector Sets: Embedding vectors for similarity search

Next Steps

Strings

Learn about the most versatile data type

Commands Reference

Explore all available commands

Build docs developers (and LLMs) love