# SMOVE

> Move a member from one set to another, atomically.

URL: https://docs.hotkv.com/commands/smove/

```
SMOVE source destination member
```

- Group: Set
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`SMOVE` removes `member` from the set at `source` and adds it to the set at
`destination` in one atomic step. `destination` is created if it does not
exist, and `source` is deleted when its last member leaves. If `member` is
already in `destination`, it is only removed from `source`.

When `source` and `destination` are the same key, nothing changes; the reply
still tells you whether `member` is in the set.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Member moved | Integer `1` | Same |
| Member not in `source`, or `source` does not exist | Integer `0` | Same |

`SMOVE` replies with a `WRONGTYPE` error if `source` exists and is not a set,
or if `destination` exists and is not a set. A missing `source` replies `0`
without looking at `destination`.

## Examples

```
127.0.0.1:6379> SADD todo "write" "test"
(integer) 2
127.0.0.1:6379> SMOVE todo done "write"
(integer) 1
127.0.0.1:6379> SMOVE todo done "deploy"
(integer) 0
127.0.0.1:6379> SMEMBERS done
1) "write"
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[SADD](https://docs.hotkv.com/commands/sadd/index.md), [SREM](https://docs.hotkv.com/commands/srem/index.md), [LMOVE](https://docs.hotkv.com/commands/lmove/index.md)