Created
February 8, 2012 21:01
-
-
Save ik5/1773844 to your computer and use it in GitHub Desktop.
Redis nested multibulk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) 1) (integer) 0 | |
2) (integer) 1328734844 | |
3) (integer) 14 | |
4) 1) "CONFIG" | |
2) "SET" | |
3) "slowlog-log-slower-than" | |
4) "1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This output is not as the original protocol at: http://redis.io/topics/protocol
"
Multi-bulk replies
Commands like LRANGE need to return multiple values (every element of the list is a value, and LRANGE needs to return more than a single element). This is accomplished using multiple bulk writes, prefixed by an initial line indicating how many bulk writes will follow. The first byte of a multi bulk reply is always *. Example:
C: LRANGE mylist 0 3
s: *4
s: $3
s: foo
s: $3
s: bar
s: $5
s: Hello
s: $5
s: World
As you can see the multi bulk reply is exactly the same format used in order to send commands to the Redis server using the unified protocol.
The first line the server sent is *4\r\n in order to specify that four bulk replies will follow. Then every bulk write is transmitted.
If the specified key does not exist, the key is considered to hold an empty list and the value 0 is sent as multi bulk count. Example:
C: LRANGE nokey 0 1
S: *0
When the BLPOP command times out, it returns the nil multi bulk reply. This type of multi bulk has count -1 and should be interpreted as a nil value. Example:
C: BLPOP key 1
S: *-1
A client library API SHOULD return a nil object and not an empty list when this happens. This is necessary to distinguish between an empty list and an error condition (for instance the timeout condition of the BLPOP command).
"