RPOP

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Pop data from the right of the list

Pops data from the right of the list. It is removed from the list.
When using a queue data structure, use LPUSH and RPOP.

Example

Command>lpush mylist value1 value2 value3 value4
Result>4
Command>lrange mylist 0 -1
Result>0) value4
1) value3
2) value2
3) value1
Command>rpop mylist
Result>value1   value1, the first value inserted, is returned
Command>lrange mylist 0 -1
Result>0) value4
1) value3
2) value2
Command>rpop mylist
Result>value2

View animation



Popping multiple values: COUNT option

Use the COUNT option to pop multiple values.
The COUNT option is available since version 6.2.

Example: Count

Command>lpush mylist value1 value2 value3 value4
Result>4
Command>rpop mylist 3
Result> 1) value1
2) value2
3) value3


Syntax

RPOP key [count]

  • Available since version 1.0.0.
  • Time complexity is O(N). N is the number of returned values.
  • The COUNT option was added in version 6.2.
Related commands LPOP, LPUSH, RPUSH
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< LPUSHS RPOP LPOP >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.