Redis Smove Command
The Redis Smove command moves the specified member element from the source collection to the destination collection.
SMOVE is an atomic operation.
If the source collection does not exist or does not contain the specified member element, the SMOVE command performs no operation and returns 0. Otherwise, the member element is removed from the source collection and added to the destination collection.
When the destination collection already contains the member element, the SMOVE command simply removes the member element from the source collection.
When source or destination is not a collection type, an error is returned.
Syntax
The basic syntax of the Redis SMOVE command is as follows:
redis 127.0.0.1:6379> SMOVE SOURCE DESTINATION MEMBER
Available Versions
>= 1.0.0
Return Value
If the member element is successfully removed, return 1. If the member element is not a member of the source collection and no operation is performed on the destination collection, then return 0.
Example
redis 127.0.0.1:6379> SADD myset1 "hello" (integer) 1 redis 127.0.0.1:6379> SADD myset1 "world" (integer) 1 redis 127.0.0.1:6379> SADD myset1 "bar" (integer) 1 redis 127.0.0.1:6379> SADD myset2 "foo" (integer) 1 redis 127.0.0.1:6379> SMOVE myset1 myset2 "bar" (integer) 1 redis 127.0.0.1:6379> SMEMBERS myset1 1) "World" 2) "Hello" redis 127.0.0.1:6379> SMEMBERS myset2 1) "foo" 2) "bar"
Other Extensions
Redis Set