What are the different data types supported by Redis?

Beginner

Answer

Redis supports several data types:

  1. String: Binary-safe strings up to 512MB
  2. Hash: Field-value pairs, like objects
  3. List: Ordered collection of strings
  4. Set: Unordered collection of unique strings
  5. Sorted Set (ZSet): Set ordered by a score
  6. Bitmap: String treated as bit array
  7. HyperLogLog: Probabilistic data structure for cardinality estimation
  8. Geospatial: Longitude/latitude coordinates
  9. Stream: Log-like data structure for message queues
SET mykey "hello"          # String
HSET user:1 name "John"    # Hash
LPUSH mylist "item1"       # List
SADD myset "member1"       # Set
ZADD myzset 1 "item1"      # Sorted Set