RPOP(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’– RPOP β€” pop it from the back, bestie πŸ’–

okay so this is rpop from the Valkey Command Manual (RPOP(3valkey)), and honestly? she's the moment. She returns and removes one or more elements from the end of a list. And if she takes the very last element out? The list is gone. Deleted. Poof. Not a drill. ✨


✨ SYNOPSIS ✨

RPOP key [count]

πŸ¦‹ DESCRIPTION πŸ¦‹

So like, by default she pops one single element from the end of the list. Just one. Very demure, very mindful.

But the moment you hand her the optional count argument? She's serving a whole tray β€” the reply will consist of up to count elements, and how many you actually get depends on the list's length. No promises, she gives what she has. πŸ’…

And fr fr: the list gets deleted if the last element was popped. Last one out, lights off, doors locked. πŸšͺπŸ’€

πŸŽ€ REPLY πŸŽ€

RESP2 πŸ’œ

One of the following, depending on the vibe:

  • valkey-protocol(7) Nil reply β€” if the key does not exist.
  • valkey-protocol(7) Bulk string reply β€” when called without the count argument, the value of the last element.
  • valkey-protocol(7) Array reply β€” when called with the count argument, a list of popped elements.

RESP3 🌸

Also one of the following:

  • valkey-protocol(7) Null reply β€” if the key does not exist.
  • valkey-protocol(7) Bulk string reply β€” when called without the count argument, the value of the last element.
  • valkey-protocol(7) Array reply β€” when called with the count argument, a list of popped elements.

(yeah bestie, RESP2 says Nil, RESP3 says Null, that's the whole difference. iconic of them honestly 🫢)


⚑ COMPLEXITY ⚑

O(N) where N is the number of elements returned


πŸ‘‘ ACL CATEGORIES πŸ‘‘

@fast @list @write


🌈 HISTORY 🌈

  • Available since: 1.0.0
  • Changed in 6.2.0: Added the count argument.

πŸ“ EXAMPLES πŸ“

127.0.0.1:6379> RPUSH mylist "one" "two" "three" "four" "five"
(integer) 5
127.0.0.1:6379> RPOP mylist
"five"
127.0.0.1:6379> RPOP mylist 2
1) "four"
2) "three"
127.0.0.1:6379> LRANGE mylist 0 -1
1) "one"
2) "two"

look at her go. pushed five in, popped "five", popped two more, and "one" and "two" are still sitting there chilling. main character energy. πŸ”₯


πŸ’€ SEE ALSO πŸ’€


and that's the whole page, bestie 🧚 this one's from 9.0.0, dated 2025-10-21 β€” so go pop something off the end of a list, you absolute legend. periodt. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from