Redis – List Rpop Command

  • Post author:
  • Post category:Redis
  • Post comments:2 Comments

Redis RPOP command removes and returns the last element of the list stored at the key.

Return Value

String reply, the value of the last element, or nil when the key does not exist.

Syntax

Following is the basic syntax of Redis RPOP command.

redis 127.0.0.1:6379> RPOP KEY_NAME

Example

redis 127.0.0.1:6379> RPUSH mylist "hello" 
(integer) 1 
redis 127.0.0.1:6379> RPUSH mylist "hello" 
(integer) 2 
redis 127.0.0.1:6379> RPUSH mylist "foo" 
(integer) 3 
redis 127.0.0.1:6379> RPUSH mylist "bar" 
(integer) 4 
redis 127.0.0.1:6379> RPOP mylist 
OK 
redis 127.0.0.1:6379> LRANGE mylist 0 -1 
1) "hello" 
2) "hello" 
3) "foo"

This Post Has 2 Comments

Leave a Reply