The string is Redis's most basic value type, a binary-safe sequence that can hold text, numbers, or serialized objects up to 512MB. Despite the name it stores any bytes, so it is used for caching JSON, counters, or even images. Commands like SET and GET read and write strings, while INCR and DECR treat them as integers atomically. Strings underpin many caching and counting patterns and are the foundation other structures build upon conceptually.
2 / 5
What is a Redis hash?
A Redis hash stores a collection of field-value pairs under a single key, much like a small object or dictionary. It is ideal for representing an entity, for example a user with fields like name and email, without serializing the whole object. Commands such as HSET, HGET, and HGETALL manipulate individual fields efficiently, so you can update one field without rewriting the rest. Hashes are memory-efficient for small objects, making them a common choice for caching structured records.
3 / 5
What is a Redis list?
A Redis list is an ordered sequence of string elements, implemented so that pushing and popping at either end is fast. Commands like LPUSH, RPUSH, LPOP, and RPOP add or remove from the head or tail, while LRANGE reads a slice. Lists are commonly used as simple queues or stacks, and blocking variants like BLPOP enable producer-consumer patterns. They preserve insertion order, distinguishing them from sets, and allow duplicate values.
4 / 5
What is a Redis sorted set?
A Redis sorted set stores unique members, each associated with a floating-point score that determines their order. Members stay sorted by score, so you can efficiently query ranges, ranks, and top-N results. Commands such as ZADD, ZRANGE, and ZRANGEBYSCORE manage and read them. Sorted sets are perfect for leaderboards, priority queues, and time-ordered data where you need both uniqueness and ranking. They combine the uniqueness of a set with the ordering power of a score index.
5 / 5
What is a Redis stream?
A Redis stream is an append-only log data type designed for event and message processing. Each entry gets an auto-generated id (typically a timestamp plus sequence) and holds field-value pairs. Producers append with XADD, and consumers read with XREAD or via consumer groups using XREADGROUP, which distribute entries among consumers and track acknowledgments. Streams support reliable, replayable messaging similar in spirit to Kafka, making Redis usable as a lightweight event broker.