Redis Lists: BLPOP
BLPOP key1 [key2 ] timeout
Redis BLPOP command is used to blocks the connection when there are no elements to pop from any of the given lists or remove and get the first element in a list if available. An element is popped from the head of the first list that is non-empty.
Syntax:
BLPOP LIST1 LIST2 .. LISTN TIMEOUT
Available since
2.0.0.
Return Value
String reply, value of element stored at key or nil
Return Value Type
String
Example: Redis BLPOP
127.0.0.1:6379> RPUSH mycolor1 R G B (integer) 3 127.0.0.1:6379> RPUSH mycolor2 Y O P (integer) 3 127.0.0.1:6379> BLPOP mycolor mycolor1 mycolor2 30 1) "mycolor1" 2) "R" 127.0.0.1:6379> BLPOP mycolor mycolor1 mycolor2 30 1) "mycolor1" 2) "G" 127.0.0.1:6379> BLPOP mycolor mycolor1 mycolor2 30 1) "mycolor1" 2) "B" 127.0.0.1:6379> BLPOP mycolor mycolor1 mycolor2 30 1) "mycolor2" 2) "Y" 127.0.0.1:6379> BLPOP mycolor mycolor1 mycolor2 30 1) "mycolor2" 2) "O" 127.0.0.1:6379> BLPOP mycolor mycolor1 mycolor2 30 1) "mycolor2" 2) "P" 127.0.0.1:6379> BLPOP mycolor mycolor1 mycolor2 30 (nil) (30.03s)
Above example will block the client for 30 seconds to execute any command. If any data comes in the specified key lists then it returns otherwise after 30 seconds nil value is returned.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework