Redis SMOVE令

1年前 (2024-04-27)
Redis SMOVE 令将 member 成员从一个(source)移动另一个(destination)。

如果 source 不存在,或者不包含指定的 member 元素,则 SMOVE 令不执行任何操作,仅返回 0。否则, member 元素从 source 中被移除,并添加到 destination 中去。

当 destination 已经包含 member 元素时, SMOVE 令只是简单地将 source 中的 member 元素删除。当 source 或 destination 不是类型时,返回一个错误信息。

可用版本

SMOVE 令可用版本:>= 1.0.0

语法

Redis SMOVE 令的基本语法如下:

SMOVE source destination member  

返回值

如果 member 元素被成功移除,返回 1。如果 member 元素不是 source 的成员,那么将返回 0 。

令演示

127.0.0.1:6379> SADD website www.biancheng网站站点" rel="nofollow" />