Reading — step 1 of 3
Pop & Length
~1 min readLists
LPOP, RPOP & LLEN
Now let's remove elements from lists.
Commands
LPOP key— remove and return head. Returns bulk string or$-1\r\nif empty/missingRPOP key— remove and return tailLLEN key— return list length as integer (:0for non-existing key)
Auto-delete Empty Lists
When all elements are popped, Redis automatically deletes the key. The key simply ceases to exist — EXISTS key returns :0, TYPE key returns +none.
Queue & Stack Patterns
- Queue (FIFO): RPUSH + LPOP (add right, take left)
- Stack (LIFO): LPUSH + LPOP (add left, take left)
These patterns are why Redis lists are so popular for job queues and message buffers.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…