SMOVE(3valkey)

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

πŸ’– SMOVE β€” like, the valkey(3valkey) manual page, but make it make sense πŸ’–

okay bestie, gather round 🫢 this is the smove command from the Valkey Command Manual, and honestly? it's giving set-to-set relocation realness ✨


✨ NAME ✨

smove β€” moves a member from one set to another. that's it. that's the whole job. iconic behavior tbh πŸ’…


🌸 SYNOPSIS 🌸

SMOVE source destination member

three little arguments, one big glow-up for your data πŸ¦‹


πŸ’œ DESCRIPTION πŸ’œ

so basically: you take member and you move it out of the set at source and into the set at destination. glow-up complete. πŸ’–

and the way that this is atomic? obsessed. in every given moment the element will appear to be a member of source or destination for other clients β€” never both, never neither. no awkward in-between era. no cap. ✨

now the plot twists:

  • if the source set doesn't exist, or it exists but doesn't contain the specified element? no operation is performed, and 0 is returned. literally nothing happens. we move on. πŸ™ˆ
  • otherwise, the element gets removed from the source set and added to the destination set. slay.
  • if the specified element already exists in the destination set, it's only removed from the source set. it's not double-added, bestie, we don't do duplicates here. πŸ’…
and if source or destination doesn't hold a set value? that's an error. 🚨 not a vibe. fix your types.

πŸŽ€ REPLY πŸŽ€

one of the following, no in-betweens:

  • valkey-protocol(7) Integer reply: 1 if the element is moved. πŸŽ‰
  • valkey-protocol(7) Integer reply: 0 if the element is not a member of source and no operation was performed. 😭

⭐ COMPLEXITY ⭐

O(1) β€” constant time, constant queen πŸ‘‘


🌈 ACL CATEGORIES 🌈

@fast @set @write


πŸ¦‹ HISTORY πŸ¦‹

  • Available since: 1.0.0 β€” an OG. a legend. a main character from day one. πŸ‘‘

πŸ’– EXAMPLES πŸ’–

here's the whole thing in action, look at her go:

127.0.0.1:6379> SADD myset "one"
(integer) 1
127.0.0.1:6379> SADD myset "two"
(integer) 1
127.0.0.1:6379> SADD myotherset "three"
(integer) 1
127.0.0.1:6379> SMOVE myset myotherset "two"
(integer) 1
127.0.0.1:6379> SMEMBERS myset
1) "one"
127.0.0.1:6379> SMEMBERS myotherset
1) "three"
2) "two"

see how "two" dipped out of myset and showed up in myotherset? she left, she arrived, she's thriving. myset is left with just "one", and myotherset is serving "three" and "two" together. periodt. πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘


Valkey 9.0.0 πŸ’œ 2025-10-21 πŸ’– and that's the whole page bestie, SMOVE(3valkey) said what she said, go move some members, ily, bye 🫢✨🌸

πŸ“¦ where this page comes from