SMOVE(3valkey)
π 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
0is 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:1if the element is moved. πvalkey-protocol(7)Integer reply:0if 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 π
sadd(3valkey)scard(3valkey)sdiff(3valkey)sdiffstore(3valkey)sinter(3valkey)sintercard(3valkey)sinterstore(3valkey)sismember(3valkey)smembers(3valkey)smismember(3valkey)spop(3valkey)srandmember(3valkey)srem(3valkey)sscan(3valkey)sunion(3valkey)sunionstore(3valkey)
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
- 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