RPOP(3valkey)
π 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 thecountargument, the value of the last element.valkey-protocol(7)Array reply β when called with thecountargument, 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 thecountargument, the value of the last element.valkey-protocol(7)Array reply β when called with thecountargument, 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
countargument.
π 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 π
blmove(3valkey)blmpop(3valkey)blpop(3valkey)brpop(3valkey)brpoplpush(3valkey)lindex(3valkey)linsert(3valkey)llen(3valkey)lmove(3valkey)lmpop(3valkey)lpop(3valkey)lpos(3valkey)lpush(3valkey)lpushx(3valkey)lrange(3valkey)lrem(3valkey)lset(3valkey)ltrim(3valkey)rpoplpush(3valkey)rpush(3valkey)rpushx(3valkey)
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
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms