H13-723_V2.0 · Question #35
Redis LIST data structure, which of the following scenarios is suitable for? (multiple choice)
The correct answer is A. Build a queue system, such as a message queue C. Get the latest N data operations: for example, get the latest 10 comments on a Weibo D. Simulate stack operation. Redis LIST is an ordered, doubly-linked list that supports push/pop operations at both ends (head and tail), making it ideal for A, C, and D. A (Queue): Using LPUSH to enqueue and RPOP to dequeue implements a classic FIFO message queue - a primary use case for Redis LIST. C…
Question
Redis LIST data structure, which of the following scenarios is suitable for? (multiple choice)
Options
- ABuild a queue system, such as a message queue
- Buniq operation, for example, get the weight value of all data in a certain period of time
- CGet the latest N data operations: for example, get the latest 10 comments on a Weibo
- DSimulate stack operation
How the community answered
(29 responses)- A76% (22)
- B24% (7)
Explanation
Redis LIST is an ordered, doubly-linked list that supports push/pop operations at both ends (head and tail), making it ideal for A, C, and D.
- A (Queue): Using
LPUSHto enqueue andRPOPto dequeue implements a classic FIFO message queue - a primary use case for Redis LIST. - C (Latest N items): You can
LPUSHnew items to the head and useLRANGE 0 N-1to efficiently retrieve the most recent N entries, perfect for feeds or comment histories. - D (Stack): Pushing and popping from the same end (
LPUSH/LPOP) gives you LIFO stack behavior natively.
Why B is wrong: Unique/deduplication operations belong to the Redis SET data structure (or ZSET for weighted scores). LIST allows duplicates and has no built-in uniqueness enforcement - using it for a "uniq" operation would require manual filtering.
Memory tip: Think of Redis LIST like a physical paper list you can add to or remove from either end - great for queues, stacks, and timelines. Whenever you see "unique" or "deduplicate," that's a SET, not a LIST.
Topics
Community Discussion
No community discussion yet for this question.