RPUSH(3valkey)

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

πŸ’– RPUSH β€” the "bestie, get in line" command πŸ’–

okay so. valkey has this thing called a list, right? and rpush is literally the girl at the door of the club going "yes babe, come in, go to the BACK." that's it. that's the command. it's giving bouncer energy but make it wholesome. 🫢

manual name for the record: 3valkey, page RPUSH(3valkey) β€” writing it down so you have receipts.


✨ SYNOPSIS ✨

RPUSH key element [element...]

🌸 DESCRIPTION 🌸

so what it does is: it takes all the values you hand it and inserts them at the tail of the list stored at key. the tail. the end. the back of the line. πŸŽ€

and if key doesn't exist yet? not a problem, bestie, she just creates it as an empty list first and then does the push. iconic behaviour honestly.

but β€” and this is the important part β€” if key is holding something that is not a list? nope. error. returned. she's not gonna force it. πŸ’€

now here's the cute part: you can push multiple elements in a single command call just by putting multiple arguments at the end. they get inserted one after the other to the tail, going from the leftmost element to the rightmost element. so the order you type is the order they land. periodt.

like, say you do RPUSH mylist a b c β€” you end up with a list where a is the first element, b is the second element, and c is the third element. exactly as typed. no plot twists. ✨


πŸ’Œ REPLY πŸ’Œ

per valkey-protocol(7), it's an Integer reply: the length of the list after the push operation. so she always tells you how big the list is now. she's a communicator. πŸ’…


🧚 COMPLEXITY 🧚

O(1) for each element added β€” so O(N) to add N elements when the command is called with multiple arguments. fast fast fast. no cap. πŸ”₯


πŸ‘‘ ACL CATEGORIES πŸ‘‘

@fast @list @write


πŸ¦‹ HISTORY πŸ¦‹

  • Available since: 1.0.0 (an OG fr fr)
  • Changed in 2.4.0: Accepts multiple element arguments. (the glow-up era ✨)

🌈 EXAMPLES 🌈

127.0.0.1:6379> RPUSH mylist "hello"
(integer) 1
127.0.0.1:6379> RPUSH mylist "world"
(integer) 2
127.0.0.1:6379> LRANGE mylist 0 -1
1) "hello"
2) "world"

look at her go. 1, then 2, then the LRANGE pulls up the whole crew. πŸ“


πŸ’œ SEE ALSO πŸ’œ


okay that's the whole page bestie, mwah πŸ’– this was version 9.0.0, dated 2025-10-21, and yes the whole thing is the RPUSH(3valkey) manual page. go push something. πŸŽ€

πŸ“¦ where this page comes from