Redis SMOVE 命令用于从集合source 中移动成员member 到集合 destination。
这个操作是原子操作。
在任何时刻,member 只会存在于source 和destination 其中之一。
如果集合source 不存在,或者要移动的成员不是集合source 的成员,什么也不执行并返回 0 。
否则,其它情况下,从集合source 中删除成员并添加到集合 destination。
如果要移动的元素在集合 destination中已经存在,那么只是从集合source中删除该成员。
如果 source 或destination 不是集合类型则返回错误。
*返回值
整数:
1移动元素成功。0如果要移动的 element 不是source的成员,什么也不执行。
*例子
redis>
SADD myset "one"
(integer) 1redis> SADD myset "two"
(integer) 1redis> SADD myotherset "three"
(integer) 1redis> SMOVE myset myotherset "two"
(integer) 1redis> SMEMBERS myset
1) "one"redis> SMEMBERS myotherset
1) "two" 2) "three"