Upstash Documentation

SMOVE

Move member between sets.
2 min read

Use SMOVE to move a member from one set to another atomically.

The reply is 1 when the member was moved and 0 when it was not in the source set, in which case nothing changes. If the member already exists in the destination it is simply removed from the source. The destination is created when it does not exist, and the source is deleted when its last member leaves.

Because the removal and the insertion happen as one step, this is the safe way to move an item between states, such as from a pending set to a done set, without a window in which it is in both or in neither.

Syntax#

Arguments#

ArgumentRequiredRepeatableDescription
<source>YesNoRedis key used as source.
<destination>YesNoRedis key used as destination.
<member>YesNoMember name.

Response#

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.

ProtocolReply
RESP2Integer: 1 if the member was moved, 0 if it is not in the source set
RESP3Integer: 1 if the member was moved, 0 if it is not in the source set
Note

Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples#

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Redis CLI
@upstash/redis
upstash_redis
ioredis
node-redis
redis-py
go-redis
jedis
redis-rs