Redis easy
Which Redis data type is most efficient for storing a complex object with multiple named fields, such as a User profile?
- A List: Best for ordered streams or simple notification queues between microservices.
- B Hash: Maps string fields to string values, ideal for representing structured objects.
- C Set: An unordered collection of unique values optimized for membership testing.
- D Bitmap: A memory-efficient way to track boolean flags across millions of integer IDs.
Answer: B. Hash: Maps string fields to string values, ideal for representing structured objects.
Redis Hashes act like small HashMaps inside a key. They are memory-optimized and allow you to update individual fields (e.g., `HSET user:1 age 30`) without the overhead of rewriting the entire serialized object.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- If the Redis memory limit is reached, what specific behavior is exhibited by the `allkeys-lru` eviction policy?
- What is the defining characteristic of a Redis 'Set' data type compared to a standard Redis 'List'?
- In the context of Redis messaging, what is the functional definition of the 'Pub/Sub' feature?
- How does the Redis background snapshotting process (`BGSAVE`) leverage the operating system's `fork()` mechanism to minimize memory overhead?
- Why does Redis proactively disconnect a Pub/Sub client that exhibits high 'output buffer' usage relative to its ingestion rate?
- How does a 'Sorted Set' (ZSET) manage its internal membership and ordering differently from a plain Set?