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 package main
var helpCommands = [][]string{ var helpCommands = [][]string{
@ -9,9 +9,11 @@ var helpCommands = [][]string{
{"BEXPIREAT", "key timestamp", "Bitmap"}, {"BEXPIREAT", "key timestamp", "Bitmap"},
{"BGET", "key", "Bitmap"}, {"BGET", "key", "Bitmap"},
{"BGETBIT", "key offset", "Bitmap"}, {"BGETBIT", "key offset", "Bitmap"},
{"BLPOP", "key [key ...] timeout", "List"},
{"BMSETBIT", "key offset value [offset value ...]", "Bitmap"}, {"BMSETBIT", "key offset value [offset value ...]", "Bitmap"},
{"BOPT", "operation destkey key [key ...]", "Bitmap"}, {"BOPT", "operation destkey key [key ...]", "Bitmap"},
{"BPERSIST", "key", "Bitmap"}, {"BPERSIST", "key", "Bitmap"},
{"BRPOP", "key [key ...] timeout", "List"},
{"BSETBIT", "key offset value", "Bitmap"}, {"BSETBIT", "key offset value", "Bitmap"},
{"BTTL", "key", "Bitmap"}, {"BTTL", "key", "Bitmap"},
{"BXSCAN", "key [MATCH match] [COUNT count]", "Bitmap"}, {"BXSCAN", "key [MATCH match] [COUNT count]", "Bitmap"},
@ -28,7 +30,7 @@ var helpCommands = [][]string{
{"EXPIREAT", "key timestamp", "KV"}, {"EXPIREAT", "key timestamp", "KV"},
{"FLUSHALL", "-", "Server"}, {"FLUSHALL", "-", "Server"},
{"FLUSHDB", "-", "Server"}, {"FLUSHDB", "-", "Server"},
{"FULLSYNC", "-", "Replication"}, {"FULLSYNC", "[NEW]", "Replication"},
{"GET", "key", "KV"}, {"GET", "key", "KV"},
{"GETSET", " key value", "KV"}, {"GETSET", " key value", "KV"},
{"HCLEAR", "key", "Hash"}, {"HCLEAR", "key", "Hash"},

View File

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

View File

@ -40,13 +40,15 @@ Table of Contents
- [HSET key field value](#hset-key-field-value) - [HSET key field value](#hset-key-field-value)
- [HVALS key](#hvals-key) - [HVALS key](#hvals-key)
- [HCLEAR key](#hclear-key) - [HCLEAR key](#hclear-key)
- [HMCLEAR key [key...]](#hmclear-key-key) - [HMCLEAR key [key ...]](#hmclear-key-key)
- [HEXPIRE key seconds](#hexpire-key-seconds) - [HEXPIRE key seconds](#hexpire-key-seconds)
- [HEXPIREAT key timestamp](#hexpireat-key-timestamp) - [HEXPIREAT key timestamp](#hexpireat-key-timestamp)
- [HTTL key](#httl-key) - [HTTL key](#httl-key)
- [HPERSIST key](#hpersist-key) - [HPERSIST key](#hpersist-key)
- [HXSCAN key [MATCH match] [COUNT count]](#hxscan-key-match-match-count-count) - [HXSCAN key [MATCH match] [COUNT count]](#hxscan-key-match-match-count-count)
- [List](#list) - [List](#list)
- [BLPOP key [key ...] timeout](#blpop-key-key--timeout)
- [BRPOP key [key ...] timeout](#brpop-key-key--timeout)
- [LINDEX key index](#lindex-key-index) - [LINDEX key index](#lindex-key-index)
- [LLEN key](#llen-key) - [LLEN key](#llen-key)
- [LPOP key](#lpop-key) - [LPOP key](#lpop-key)
@ -883,6 +885,35 @@ See [XSCAN](#xscan-key-match-match-count-count) for more information.
## List ## 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 ### 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. 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. When the value at key is not a list, an error is returned.