Redis easy
Which internal Redis data structure is most suitable for implementing a simple First-In-First-Out (FIFO) Message Queue?
- A Set: A collection of unique strings that does not preserve addition order.
- B Hash: A map between string fields and string values for object storage.
- C List: A linked list of strings that supports efficient pushing and popping.
- D String: A single binary-safe buffer limited to 512MB of total data data size.
Answer: C. List: A linked list of strings that supports efficient pushing and popping.
Redis Lists are Linked Lists. You can push to the left (`LPUSH`) and pop from the right (`RPOP`) to create a perfect message queue, ensuring that the first item added is the first one processed.
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?