redis RPOPLPUSH 命令详解

RPOPLPUSH source destination
命令 RPOPLPUSH 在一个原子时间内,执行以下两个动作:
将列表 source 中的最后一个元素 ( 尾元素 ) 弹出,并返回给客户端。
source 弹出的元素插入到列表 destination ,作为 destination 列表的的头元素。
举个例子,你有两个列表
source destination source 列表有元素 a, b, c destination 列表有元
x, y, z ,执行 RPOPLPUSH source destination 之后, source 列表包含元素 a, b destination
表包含元素
c, x, y, z ,并且元素 c 会被返回给客户端。
如果
source 不存在,值 nil 被返回,并且不执行其他动作。
如果
source destination 相同,则列表中的表尾元素被移动到表头,并返回该元素,可以把这种特殊

情况视作列表的旋转 (rotation) 操作

RPOP - 从列表尾部取出 R-right

Lpush - 放入列表头部 L-left


猜你喜欢

转载自blog.csdn.net/aa1358075776/article/details/80960362