[{"id":"redisintermediate-001","courseId":"redis-intermediate","domain":"data-structures","topic":"Popping several list elements","prompt":"A worker drains a queue with LPOP jobs 20. At that moment the list holds 7 jobs. What comes back, and what is left of the key?","hint":"The count is a maximum, not a promise, and the reply arrives in one piece.","source":"https://redis.io/docs/latest/commands/lpop/","interaction":{"type":"single"},"options":[{"id":"a","text":"An array of all 7 jobs, and the key is gone","why":"With a count, LPOP returns up to count elements, and the list is deleted once its last element is popped."},{"id":"b","text":"An array of 20 entries, padded with nil for the missing jobs","whyNot":"The reply holds only the elements that existed; nothing is padded."},{"id":"c","text":"An error, because count is larger than the list length","whyNot":"count may exceed the length; the reply is simply shorter than requested."},{"id":"d","text":"Seven separate bulk-string replies, one per popped job","whyNot":"One call with count gives one array reply, not many replies."}],"answer":"a","explanation":"LPOP key count removes up to count elements from the head and returns them as a single array reply; the key is deleted when the last element is popped.","concept":"LPOP key count removes up to count elements from the head and returns them as a single array reply; the key is deleted when the last element is popped.","rev":1,"kind":"scenario","code":"redis> RPUSH jobs a b c d e f g\n(integer) 7\nredis> LPOP jobs 20\n?","takeaways":["A count larger than the list is fine: you get what is there.","Popping the last element deletes the key."]},{"id":"redisintermediate-002","courseId":"redis-intermediate","domain":"data-structures","topic":"Atomic moves between lists","prompt":"A consumer takes jobs with LMOVE queue processing LEFT RIGHT, and only removes one from processing after the work succeeds. It crashes right after the LMOVE returns. What is true of the job?","hint":"Think about what happens inside the single atomic step between the two lists.","source":"https://redis.io/docs/latest/commands/lmove/","interaction":{"type":"single"},"options":[{"id":"a","text":"It is still in processing, so another client can put it back","why":"The pop and push are atomic, so the job sits in the processing list until an LREM removes it."},{"id":"b","text":"It is lost, because LMOVE removed it from the queue","whyNot":"The removal and the push happen together; the element still exists in the destination list."},{"id":"c","text":"It exists in both queue and processing at once","whyNot":"LMOVE is one atomic pop-and-push, so the element lives in exactly one list afterwards."},{"id":"d","text":"Redis repeats the LMOVE when the client reconnects","whyNot":"Redis does not replay commands for a client that died; re-queueing is left to another client."}],"answer":"a","explanation":"LMOVE atomically pops from one list and pushes to another; that is the reliable queue pattern, where a separate client re-queues items left too long in the processing list.","concept":"LMOVE atomically pops from one list and pushes to another; that is the reliable queue pattern, where a separate client re-queues items left too long in the processing list.","rev":1,"kind":"scenario","code":"LMOVE queue processing LEFT RIGHT\n# consumer crashes here\n# LREM processing 1 job never runs","takeaways":["LMOVE closes the window where a job is popped but not yet recorded.","The processing list, not Redis, is what makes the queue recoverable."]},{"id":"redisintermediate-003","courseId":"redis-intermediate","domain":"data-structures","topic":"Set intersection","prompt":"A nightly job runs SINTER active:2026-10 all-users. The key active:2026-10 expired an hour ago. What does the command return?","hint":"Set algebra still has a rule for a key that is not there.","source":"https://redis.io/docs/latest/commands/sinter/","interaction":{"type":"single"},"options":[{"id":"a","text":"An empty array","why":"A missing key is treated as an empty set, and intersecting with an empty set always gives an empty set."},{"id":"b","text":"Every member of all-users","whyNot":"A missing key is an empty set, not a wildcard; it cannot be skipped over."},{"id":"c","text":"An error naming the missing key","whyNot":"SINTER accepts keys that do not exist; it does not fail."},{"id":"d","text":"The members all-users held before the expiry","whyNot":"An expired key is gone; there is no earlier version left to intersect."}],"answer":"a","explanation":"SINTER intersects all the given sets, treating keys that do not exist as empty sets, so any missing key empties the result.","concept":"SINTER intersects all the given sets, treating keys that do not exist as empty sets, so any missing key empties the result.","rev":1,"kind":"scenario","code":"redis> SINTER active:2026-10 all-users\n?","takeaways":["A silent empty result from SINTER often means one input key expired."]},{"id":"redisintermediate-004","courseId":"redis-intermediate","domain":"data-structures","topic":"Exclusive score bounds","prompt":"A teammate wants members scoring above 1 and up to 2 inclusive, and runs the command below. What is the reply?","hint":"One character opens a bound; a bare number leaves it closed.","source":"https://redis.io/docs/latest/commands/zrangebyscore/","interaction":{"type":"single"},"options":[{"id":"a","text":"Only two","why":"The leading ( excludes 1, while 2 has no prefix and stays inclusive."},{"id":"b","text":"one and two","whyNot":"The ( on the lower bound drops one, which sits exactly on 1."},{"id":"c","text":"two and three","whyNot":"The upper bound 2 is closed, so three at score 3 is outside the range."},{"id":"d","text":"An empty array","whyNot":"An empty reply needs both bounds open, as in (1 (2."}],"answer":"a","explanation":"Score bounds are inclusive by default; prefix a bound with ( to exclude it, and use -inf and +inf when there is no bound.","concept":"Score bounds are inclusive by default; prefix a bound with ( to exclude it, and use -inf and +inf when there is no bound.","rev":1,"kind":"scenario","code":"redis> ZADD myzset 1 one 2 two 3 three\nredis> ZRANGEBYSCORE myzset (1 2\n?","takeaways":["(1 2 and 1 (2 differ; only the prefixed side is exclusive."]},{"id":"redisintermediate-005","courseId":"redis-intermediate","domain":"data-structures","topic":"Lexicographic sorted set ranges","prompt":"Members are added with the scores below. A teammate then runs ZRANGEBYLEX board - + to list every name in alphabetical order. What does the documentation say to expect?","hint":"The command's contract assumes something about the scores of the members.","source":"https://redis.io/docs/latest/commands/zrangebylex/","interaction":{"type":"single"},"options":[{"id":"a","text":"Nothing is guaranteed about the members or their order","why":"Redis only defines lexicographic ranges when every member has the same score; with mixed scores the result is unspecified."},{"id":"b","text":"alice, bob, carol in ascending score order","whyNot":"Score ordering belongs to ZRANGEBYSCORE; ZRANGEBYLEX makes no such promise."},{"id":"c","text":"alice, bob, carol in byte order whatever the scores","whyNot":"Byte ordering is only meaningful once all members share one score."},{"id":"d","text":"An error, because the scores are not all equal","whyNot":"The command does not check the scores; it just returns an unspecified result."}],"answer":"a","explanation":"ZRANGEBYLEX is defined for a sorted set whose members all have the same score; if scores differ, the returned elements are unspecified.","concept":"ZRANGEBYLEX is defined for a sorted set whose members all have the same score; if scores differ, the returned elements are unspecified.","rev":1,"kind":"scenario","code":"redis> ZADD board 10 alice 20 bob 5 carol\nredis> ZRANGEBYLEX board - +\n?","takeaways":["Give every member score 0 when using a sorted set as a lexicographic index."]}]