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#
| Argument | Required | Repeatable | Description |
|---|---|---|---|
<source> | Yes | No | Redis key used as source. |
<destination> | Yes | No | Redis key used as destination. |
<member> | Yes | No | Member 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.
| Protocol | Reply |
|---|---|
| RESP2 | Integer: 1 if the member was moved, 0 if it is not in the source set |
| RESP3 | Integer: 1 if the member was moved, 0 if it is not in the source set |
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.