RPOP 公司
语法
RPOP key [count]
- 从以下位置开始可用:
- 1.0.0
- 时间复杂度:
- O(N),其中 N 是返回的元素数
- ACL 类别:
-
@write
,@list
,@fast
,
删除并返回存储在key
.
默认情况下,该命令从列表末尾弹出单个元素。
当提供可选的count
参数,则 REPLY 将由 up 组成
自count
元素,具体取决于列表的长度。
例子
Give these commands a try in the interactive console:
RESP2 Reply
One of the following:
- Nil reply: if the key does not exist.
- Bulk string reply: when called without the count argument, the value of the last element.
- Array reply: when called with the count argument, a list of popped elements.
RESP3 Reply
One of the following:
- Null reply: if the key does not exist.
- Bulk string reply: when called without the count argument, the value of the last element.
- Array reply: when called with the count argument, a list of popped elements.
History
- Starting with Redis version 6.2.0: Added the
count
argument.