Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 769 Bytes

07.markdown

File metadata and controls

23 lines (17 loc) · 769 Bytes

So far we explored the commands that let you add elements to the list, and LRANGE that let you inspect ranges of the list. A fundamental functionality of Redis lists is the ability to remove, and return to the client at the same time, elements in the head or the tail of the list.

LPOP removes the first element from the list and returns it.


    LPOP friends => "Sam"

RPOP removes the last element from the list and returns it.


    RPOP friends => "3"

Note that the list now only has four elements:


    LLEN friends => 4
    LRANGE friends 0 -1 => 1) "Alice" 2) "Bob" 3) "1" 4) "2"