From ce64e7364c74d84d0b6844a4bbf53c0fde7d9b2e Mon Sep 17 00:00:00 2001 From: silentsai Date: Tue, 15 Jul 2014 18:15:03 +0800 Subject: [PATCH] add some api describtion for the bit type --- doc/commands.md | 110 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/doc/commands.md b/doc/commands.md index 90d7199..007eea0 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -70,7 +70,7 @@ Table of Contents - [ZREMRANGEBYRANK key start stop](#zremrangebyrank-key-start-stop) - [ZREMRANGEBYSCORE key min max](#zremrangebyscore-key-min-max) - [ZREVRANGE key start stop [WITHSCORES]](#zrevrange-key-start-stop-withscores) - - [ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]](#zrevrangebyscore--key-max-min-withscores-limit-offset-count) + - [ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]](#zrevrangebyscore-key-max-min-withscores-limit-offset-count) - [ZREVRANK key member](#zrevrank-key-member) - [ZSCORE key member](#zscore-key-member) - [ZCLEAR key](#zclear-key) @@ -79,6 +79,16 @@ Table of Contents - [ZEXPIREAT key timestamp](#zexpireat-key-timestamp) - [ZTTL key](#zttl-key) - [ZPERSIST key](#zpersist-key) +- [Bitmap](#bitmap) + - [BSETBIT key offset value](#bsetbit-key-offset-value) + - [BGETBIT key offset](#bsetbit-key-offset) + - [BGET key](#bget-key) + - [BCOUNT key [start, end]](#bcount-key-start-end) + - [BEXPIRE key seconds](#bexpire-key-seconds) + - [BEXPIREAT key timestamp](#bexpireat-key-timestamp) + - [BTTL key](#bttl-key) + - [BPERSIST key](#bpersist-key) + - [Replication](#replication) - [SLAVEOF host port](#slaveof-host-port) - [FULLSYNC](#fullsync) @@ -1617,6 +1627,104 @@ ledis> ZTTL mset ``` +## bitmap + +### BSETBIT key offset value + +Sets or clear the bit at `offset` in the binary data sotred at `key`. +The bit is either set or cleared depending on `value`, which can be either `0` or `1`. +The *offset* argument is required to be qual to 0, and smaller than +2^23 (this means bitmap limits to 8MB). + +**Return value** + +int64 : the original bit value stored at offset. + +**Examples** + +``` +ledis> BSETBIT flag 0 1 +(integer) 0 +ledis> BSETBIT flag 0 0 +(integer) 1 +ledis> BGETBIT flag 0 99 +ERR invalid command param +``` + + +### BGETBIT key offset + +Returns the bit value at `offset` in the string value stored at `key`. +When *offset* beyond the data length, ot the target data is not exist, the bit value will be 0 always. + +**Return value** + +int64 : the bit value stored at offset. + +**Examples** + +``` +ledis> BSETBIT flag 1024 1 +(integer) 0 +ledis> BGETBIT flag 0 +(integer) 0 +ledis> BGETBIT flag 1024 +(integer) 1 +ledis> BGETBIT flag 65535 +(integer) 0 +``` + + +### BCOUNT key [start end] + +Count the number of set bits in a bitmap. + +**Return value** + +int64 : The number of bits set to 1. + +**Examples** + +``` + +``` + + +### BGET key + +Returns the whole binary data stored at `key`. + +**Return value** + +bulk: the raw value of key, or nil when key does not exist. + +**Examples** + +``` + +``` + + +### BEXPIRE key seconds + +(refer to `expire` api for other types) + + +### BEXPIREAT key timestamp + +(refer to `expireat` api for other types) + + +### BTTL key + +(refer to `ttl` api for other types) + + +### PERSIST key + +(refer to `persist` api for other types) + + ## Replication ### SLAVEOF host port