update list block pop

This commit is contained in:
siddontang 2014-10-17 11:41:15 +08:00
parent f715de3561
commit 79d0f9ff64
3 changed files with 46 additions and 3 deletions

View File

@ -1,4 +1,4 @@
//This file was generated by .tools/generate_commands.py on Fri Oct 10 2014 09:08:54 +0800
//This file was generated by .tools/generate_commands.py on Fri Oct 17 2014 11:39:51 +0800
package main
var helpCommands = [][]string{
@ -9,9 +9,11 @@ var helpCommands = [][]string{
{"BEXPIREAT", "key timestamp", "Bitmap"},
{"BGET", "key", "Bitmap"},
{"BGETBIT", "key offset", "Bitmap"},
{"BLPOP", "key [key ...] timeout", "List"},
{"BMSETBIT", "key offset value [offset value ...]", "Bitmap"},
{"BOPT", "operation destkey key [key ...]", "Bitmap"},
{"BPERSIST", "key", "Bitmap"},
{"BRPOP", "key [key ...] timeout", "List"},
{"BSETBIT", "key offset value", "Bitmap"},
{"BTTL", "key", "Bitmap"},
{"BXSCAN", "key [MATCH match] [COUNT count]", "Bitmap"},
@ -28,7 +30,7 @@ var helpCommands = [][]string{
{"EXPIREAT", "key timestamp", "KV"},
{"FLUSHALL", "-", "Server"},
{"FLUSHDB", "-", "Server"},
{"FULLSYNC", "-", "Replication"},
{"FULLSYNC", "[NEW]", "Replication"},
{"GET", "key", "KV"},
{"GETSET", " key value", "KV"},
{"HCLEAR", "key", "Hash"},

View File

@ -255,6 +255,16 @@
"group": "List",
"readonly": true
},
"BLPOP": {
"arguments": "key [key ...] timeout",
"group": "List",
"readonly": false
},
"BRPOP": {
"arguments": "key [key ...] timeout",
"group": "List",
"readonly": false
},
"MGET": {
"arguments": "key [key ...]",
"group": "KV",

View File

@ -47,6 +47,8 @@ Table of Contents
- [HPERSIST key](#hpersist-key)
- [HXSCAN key [MATCH match] [COUNT count]](#hxscan-key-match-match-count-count)
- [List](#list)
- [BLPOP key [key ...] timeout](#blpop-key-key--timeout)
- [BRPOP key [key ...] timeout](#brpop-key-key--timeout)
- [LINDEX key index](#lindex-key-index)
- [LLEN key](#llen-key)
- [LPOP key](#lpop-key)
@ -883,6 +885,35 @@ See [XSCAN](#xscan-key-match-match-count-count) for more information.
## List
### BLPOP key [key ...] timeout
BLPOP is a blocking list pop primitive. It is the blocking version of LPOP because it blocks the connection when there are no elements to pop from any of the given lists. An element is popped from the head of the first list that is non-empty, with the given keys being checked in the order that they are given.
When BLPOP causes a client to block and a non-zero timeout is specified, the client will unblock returning a nil multi-bulk value when the specified timeout has expired.
The timeout argument is interpreted as an double value specifying the maximum number of seconds to block. You can use 0.005 format to support milliseconds timeout.
A timeout of zero can be used to block indefinitely.
**Return value**
array:
+ A nil multi-bulk when no element could be popped and the timeout expired.
+ A two-element multi-bulk with the first element being the name of the key where an element was popped and the second element being the value of the popped element.
**Examples**
```
ledis> RPUSH list1 a b c
(integer) 3
ledis> BLPOP list1 list2 0
1) "list1"
2) "a"
```
### BRPOP key [key ...] timeout
See [BLPOP key [key ...] timeout](#blpop-key-key--timeout) for more information.
### LINDEX key index
Returns the element at index index in the list stored at key. The index is zero-based, so 0 means the first element, 1 the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here, `-1` means the last element, `-2` means the penultimate and so forth.
When the value at key is not a list, an error is returned.