Redis Lists: RPOP
Redis RPOP Command
Redis RPOP command is used to remove and returns the last element of the list stored at key.
Here are some common uses and scenarios for the "RPOP" command:
- Queue Operations: Implement last-in, first-out (LIFO) queue processing.
- Task Management: Handle tasks in a distributed system where workers dequeue tasks from the end of a list.
- Event Handling: Process events or messages in the order they were added to a list, starting from the most recent.
- Load Balancing: Distribute workload among multiple workers by having them dequeue tasks from the end of a list.
Syntax:
RPOP KEY_NAME
Available since
1.0.0.
Return Value
String reply, the value of the last element, or nil when a key does not exist.
Return Value Type
String
Example: Redis RPOP
127.0.0.1:6379> LPUSH mycolor1 white black red blue (integer) 4 127.0.0.1:6379> LRANGE mycolor1 0 -1 1) "blue" 2) "red" 3) "black" 4) "white" 127.0.0.1:6379> RPOP mycolor1 "white" 127.0.0.1:6379> LRANGE mycolor1 0 -1 1) "blue" 2) "red" 3) "black" 127.0.0.1:6379> RPOP mycolor1 "black" 127.0.0.1:6379> LPOP mycolor1 "blue"
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/redis/redis-rpop-key.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics