Latest web development tutorials

Redis Rpop command

Redis list (List)

Redis Rpop command is used to remove and return the last element of the list.

grammar

redis Rpop basic command syntax is as follows:

redis 127.0.0.1:6379> RPOP KEY_NAME 

Available versions

> = 1.0.0

return value

The last element of the list. When the list does not exist, it returns nil.

Examples

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"

Redis list (List)