forked from mirror/ledisdb
remove bitmap type
This commit is contained in:
parent
c4380b6406
commit
c2f8405c17
|
@ -2,7 +2,7 @@
|
|||
|
||||
[![Build Status](https://travis-ci.org/siddontang/ledisdb.svg?branch=develop)](https://travis-ci.org/siddontang/ledisdb)
|
||||
|
||||
Ledisdb is a high-performance NoSQL database, similar to Redis, written in [Go](http://golang.org/). It supports many data structures including kv, list, hash, zset, bitmap,set.
|
||||
Ledisdb is a high-performance NoSQL database, similar to Redis, written in [Go](http://golang.org/). It supports many data structures including kv, list, hash, zset, set.
|
||||
|
||||
LedisDB now supports multiple different databases as backends.
|
||||
|
||||
|
@ -11,7 +11,7 @@ LedisDB now supports multiple different databases as backends.
|
|||
|
||||
## Features
|
||||
|
||||
+ Rich data structure: KV, List, Hash, ZSet, Bitmap, Set.
|
||||
+ Rich data structure: KV, List, Hash, ZSet, Set.
|
||||
+ Data storage is not limited by RAM.
|
||||
+ Various backends supported: LevelDB, goleveldb, LMDB, RocksDB, BoltDB, RAM.
|
||||
+ Supports transactions using LMDB or BotlDB.
|
||||
|
|
|
@ -1,25 +1,14 @@
|
|||
//This file was generated by .tools/generate_commands.py on Mon Mar 02 2015 14:43:25 +0800
|
||||
//This file was generated by .tools/generate_commands.py on Tue Mar 03 2015 08:58:38 +0800
|
||||
package main
|
||||
|
||||
var helpCommands = [][]string{
|
||||
{"APPEND", "key value", "KV"},
|
||||
{"BCOUNT", "key [start end]", "Bitmap"},
|
||||
{"BDELETE", "key", "ZSet"},
|
||||
{"BEGIN", "-", "Transaction"},
|
||||
{"BEXPIRE", "key seconds", "Bitmap"},
|
||||
{"BEXPIREAT", "key timestamp", "Bitmap"},
|
||||
{"BGET", "key", "Bitmap"},
|
||||
{"BGETBIT", "key offset", "Bitmap"},
|
||||
{"BITCOUNT", "key [start] [end]", "KV"},
|
||||
{"BITOP", "operation destkey key [key ...]", "KV"},
|
||||
{"BITPOS", "key bit [start] [end]", "KV"},
|
||||
{"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"},
|
||||
{"COMMIT", "-", "Transaction"},
|
||||
{"CONFIG REWRITE", "-", "Server"},
|
||||
{"DECR", "key", "KV"},
|
||||
|
|
|
@ -5,10 +5,6 @@ so you can easily write your own LedisDB client based on a Redis one.
|
|||
|
||||
Before you write a client, you must know some differences between LedisDB and Redis.
|
||||
|
||||
## Data Structure
|
||||
|
||||
LedisDB has no Strings data type but KV and Bitmap, any some Keys and Strings commands in Redis will only affect KV data, and "bit" commands affect Bitmap.
|
||||
|
||||
## Del
|
||||
|
||||
In Redis, `del` can delete all type data, like String, Hash, List, etc, but in LedisDB, `del` can only delete KV data. To delete other type data, you will use "clear" commands.
|
||||
|
@ -17,8 +13,7 @@ In Redis, `del` can delete all type data, like String, Hash, List, etc, but in L
|
|||
+ Hash: `hclear`, `hmclear`
|
||||
+ List: `lclear`, `lmclear`
|
||||
+ Set: `sclear`, `smclear`
|
||||
+ Zset: `zclear`, `zmclear`
|
||||
+ Bitmap: `bclear`, `bmclear`
|
||||
+ ZSet: `zclear`, `zmclear`
|
||||
|
||||
## Expire, Persist, and TTL
|
||||
|
||||
|
@ -29,7 +24,6 @@ The same for Del.
|
|||
+ List: `lexpire`, `lpersist`, `lttl`
|
||||
+ Set: `sexpire`, `spersist`, `sttl`
|
||||
+ Zset: `zexpire`, `zpersist`, `zttl`
|
||||
+ Bitmap: `bexpire`, `bpersist`, `bttl`
|
||||
|
||||
## ZSet
|
||||
|
||||
|
@ -47,14 +41,14 @@ Transaction API:
|
|||
|
||||
## Scan
|
||||
|
||||
LedisDB supplies `xscan`, `xrevscan`, etc, to fetch data iteratively and reverse iteratively.
|
||||
LedisDB supplies `xscan`, `xhscan`, `xsscan`, `xzscan` to fetch data iteratively and reverse iteratively.
|
||||
|
||||
+ KV: `xscan`, `xrevscan`
|
||||
+ Hash: `hxscan`, `hxrevscan`, `xhscan`, `xhrevscan`
|
||||
+ List: `lxscan`, `lxrevscan`, `xlscan`, `xlrevscan`
|
||||
+ Set: `sxscan` , `sxrevscan`, `xsscan`, `xsrevscan`
|
||||
+ Zset: `zxscan`, `zxrevscan`, `xzscan`, `xzrevscan`
|
||||
+ Bitmap: `bxscan`, `bxrevscan`, `xbscan`, `xbrevscan`
|
||||
```
|
||||
XSCAN type cursor [MATCH match] [COUNT count]
|
||||
XHSCAN key cursor [MATCH match] [COUNT count]
|
||||
XSSCAN key cursor [MATCH match] [COUNT count]
|
||||
XZSCAN key cursor [MATCH match] [COUNT count]
|
||||
```
|
||||
|
||||
## DUMP
|
||||
|
||||
|
|
|
@ -1,59 +1,4 @@
|
|||
{
|
||||
"BCOUNT": {
|
||||
"arguments": "key [start end]",
|
||||
"group": "Bitmap",
|
||||
"readonly": true
|
||||
},
|
||||
"BDELETE": {
|
||||
"arguments": "key",
|
||||
"group": "ZSet",
|
||||
"readonly": false
|
||||
},
|
||||
"BEXPIRE": {
|
||||
"arguments": "key seconds",
|
||||
"group": "Bitmap",
|
||||
"readonly": false
|
||||
},
|
||||
"BEXPIREAT": {
|
||||
"arguments": "key timestamp",
|
||||
"group": "Bitmap",
|
||||
"readonly": false
|
||||
},
|
||||
"BGET": {
|
||||
"arguments": "key",
|
||||
"group": "Bitmap",
|
||||
"readonly": true
|
||||
},
|
||||
"BGETBIT": {
|
||||
"arguments": "key offset",
|
||||
"group": "Bitmap",
|
||||
"readonly": true
|
||||
},
|
||||
"BMSETBIT": {
|
||||
"arguments": "key offset value [offset value ...]",
|
||||
"group": "Bitmap",
|
||||
"readonly": false
|
||||
},
|
||||
"BOPT": {
|
||||
"arguments": "operation destkey key [key ...]",
|
||||
"group": "Bitmap",
|
||||
"readonly": false
|
||||
},
|
||||
"BPERSIST": {
|
||||
"arguments": "key",
|
||||
"group": "Bitmap",
|
||||
"readonly": false
|
||||
},
|
||||
"BSETBIT": {
|
||||
"arguments": "key offset value",
|
||||
"group": "Bitmap",
|
||||
"readonly": false
|
||||
},
|
||||
"BTTL": {
|
||||
"arguments": "key",
|
||||
"group": "Bitmap",
|
||||
"readonly": true
|
||||
},
|
||||
"DECR": {
|
||||
"arguments": "key",
|
||||
"group": "KV",
|
||||
|
|
454
doc/commands.md
454
doc/commands.md
|
@ -1,158 +1,157 @@
|
|||
## Summary
|
||||
|
||||
ledisdb use redis protocol called RESP(REdis Serialization Protocol), [here](http://redis.io/topics/protocol).
|
||||
Ledisdb use redis protocol called RESP(REdis Serialization Protocol), [here](http://redis.io/topics/protocol).
|
||||
|
||||
ledisdb all commands return RESP format and it will use `int64` instead of `RESP integer`, `string` instead of `RESP simple string`, `bulk string` instead of `RESP bulk string`, and `array` instead of `RESP arrays` below.
|
||||
Ledisdb all commands return RESP format and it will use `int64` instead of `RESP integer`, `string` instead of `RESP simple string`, `bulk string` instead of `RESP bulk string`, and `array` instead of `RESP arrays` below.
|
||||
|
||||
Table of Contents
|
||||
=================
|
||||
Most of the Ledisdb's commands are the same as Redis's, you can see the redis commands document for detailed information too.
|
||||
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
**Commands List**
|
||||
|
||||
- [Summary](#summary)
|
||||
- [KV](#kv)
|
||||
- [DECR key](#decr-key)
|
||||
- [DECRBY key decrement](#decrby-key-decrement)
|
||||
- [DEL key [key ...]](#del-key-key-)
|
||||
- [EXISTS key](#exists-key)
|
||||
- [GET key](#get-key)
|
||||
- [GETSET key value](#getset-key-value)
|
||||
- [INCR key](#incr-key)
|
||||
- [INCRBY key increment](#incrby-key-increment)
|
||||
- [MGET key [key ...]](#mget-key-key-)
|
||||
- [MSET key value [key value ...]](#mset-key-value-key-value-)
|
||||
- [SET key value](#set-key-value)
|
||||
- [SETNX key value](#setnx-key-value)
|
||||
- [SETEX key seconds value](#setex-key-seconds-value)
|
||||
- [EXPIRE key seconds](#expire-key-seconds)
|
||||
- [EXPIREAT key timestamp](#expireat-key-timestamp)
|
||||
- [TTL key](#ttl-key)
|
||||
- [PERSIST key](#persist-key)
|
||||
- [DUMP key](#dump-key)
|
||||
- [DECR key](#decr-key)
|
||||
- [DECRBY key decrement](#decrby-key-decrement)
|
||||
- [DEL key [key ...]](#del-key-key-)
|
||||
- [EXISTS key](#exists-key)
|
||||
- [GET key](#get-key)
|
||||
- [GETSET key value](#getset-key-value)
|
||||
- [INCR key](#incr-key)
|
||||
- [INCRBY key increment](#incrby-key-increment)
|
||||
- [MGET key [key ...]](#mget-key-key-)
|
||||
- [MSET key value [key value ...]](#mset-key-value-key-value-)
|
||||
- [SET key value](#set-key-value)
|
||||
- [SETNX key value](#setnx-key-value)
|
||||
- [SETEX key seconds value](#setex-key-seconds-value)
|
||||
- [EXPIRE key seconds](#expire-key-seconds)
|
||||
- [EXPIREAT key timestamp](#expireat-key-timestamp)
|
||||
- [TTL key](#ttl-key)
|
||||
- [PERSIST key](#persist-key)
|
||||
- [DUMP key](#dump-key)
|
||||
- [APPEND key value](#append-key-value)
|
||||
- [GETRANGE key start end](#getrange-key-start-end)
|
||||
- [SETRANGE key offset value](#setrange-key-offset-value)
|
||||
- [STRLEN key](#strlen-key)
|
||||
- [BITCOUNT key [start] [end]](#bitcount-key-start-end)
|
||||
- [BITOP operation destkey key [key ...]](#bitop-operation-destkey-key-key-)
|
||||
- [BITPOS key bit [start] [end]](#bitpos-key-bit-start-end)
|
||||
- [GETBIT key offset](#getbit-key-offset)
|
||||
- [SETBIT key offset value](#setbit-key-offset-value)
|
||||
- [Hash](#hash)
|
||||
- [HDEL key field [field ...]](#hdel-key-field-field-)
|
||||
- [HEXISTS key field](#hexists-key-field)
|
||||
- [HGET key field](#hget-key-field)
|
||||
- [HGETALL key](#hgetall-key)
|
||||
- [HINCRBY key field increment](#hincrby-key-field-increment)
|
||||
- [HKEYS key](#hkeys-key)
|
||||
- [HLEN key](#hlen-key)
|
||||
- [HMGET key field [field ...]](#hmget-key-field-field-)
|
||||
- [HMSET key field value [field value ...]](#hmset-key-field-value-field-value-)
|
||||
- [HSET key field value](#hset-key-field-value)
|
||||
- [HVALS key](#hvals-key)
|
||||
- [HCLEAR key](#hclear-key)
|
||||
- [HMCLEAR key [key ...]](#hmclear-key-key)
|
||||
- [HEXPIRE key seconds](#hexpire-key-seconds)
|
||||
- [HEXPIREAT key timestamp](#hexpireat-key-timestamp)
|
||||
- [HTTL key](#httl-key)
|
||||
- [HPERSIST key](#hpersist-key)
|
||||
- [HDUMP key](#hdump-key)
|
||||
- [HDEL key field [field ...]](#hdel-key-field-field-)
|
||||
- [HEXISTS key field](#hexists-key-field)
|
||||
- [HGET key field](#hget-key-field)
|
||||
- [HGETALL key](#hgetall-key)
|
||||
- [HINCRBY key field increment](#hincrby-key-field-increment)
|
||||
- [HKEYS key](#hkeys-key)
|
||||
- [HLEN key](#hlen-key)
|
||||
- [HMGET key field [field ...]](#hmget-key-field-field-)
|
||||
- [HMSET key field value [field value ...]](#hmset-key-field-value-field-value-)
|
||||
- [HSET key field value](#hset-key-field-value)
|
||||
- [HVALS key](#hvals-key)
|
||||
- [HCLEAR key](#hclear-key)
|
||||
- [HMCLEAR key [key...]](#hmclear-key-key)
|
||||
- [HEXPIRE key seconds](#hexpire-key-seconds)
|
||||
- [HEXPIREAT key timestamp](#hexpireat-key-timestamp)
|
||||
- [HTTL key](#httl-key)
|
||||
- [HPERSIST key](#hpersist-key)
|
||||
- [HDUMP key](#hdump-key)
|
||||
- [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)
|
||||
- [LRANGE key start stop](#lrange-key-start-stop)
|
||||
- [LPUSH key value [value ...]](#lpush-key-value-value-)
|
||||
- [RPOP key](#rpop-keuser-content-y)
|
||||
- [RPUSH key value [value ...]](#rpush-key-value-value-)
|
||||
- [LCLEAR key](#lclear-key)
|
||||
- [LMCLEAR key [key...]](#lmclear-key-key-)
|
||||
- [LEXPIRE key seconds](#lexpire-key-seconds)
|
||||
- [LEXPIREAT key timestamp](#lexpireat-key-timestamp)
|
||||
- [LTTL key](#lttl-key)
|
||||
- [LPERSIST key](#lpersist-key)
|
||||
- [LDUMP key](#ldump-key)
|
||||
- [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)
|
||||
- [LRANGE key start stop](#lrange-key-start-stop)
|
||||
- [LPUSH key value [value ...]](#lpush-key-value-value-)
|
||||
- [RPOP key](#rpop-key)
|
||||
- [RPUSH key value [value ...]](#rpush-key-value-value-)
|
||||
- [LCLEAR key](#lclear-key)
|
||||
- [LMCLEAR key [key ...]](#lmclear-key-key-)
|
||||
- [LEXPIRE key seconds](#lexpire-key-seconds)
|
||||
- [LEXPIREAT key timestamp](#lexpireat-key-timestamp)
|
||||
- [LTTL key](#lttl-key)
|
||||
- [LPERSIST key](#lpersist-key)
|
||||
- [LDUMP key](#ldump-key)
|
||||
- [Set](#set)
|
||||
- [SADD key member [member ...]](#sadd-key-member-member-)
|
||||
- [SCARD key](#scard-key)
|
||||
- [SDIFF key [key ...]](#sdiff-key-key-)
|
||||
- [SDIFFSTORE destination key [key ...]](#sdiffstore-destination-key-key-)
|
||||
- [SINTER key [key ...]](#sinter-key-key-)
|
||||
- [SINTERSTORE destination key [key ...]](#sinterstore-destination-key-key-)
|
||||
- [SISMEMBER key member](#sismember-key-member)
|
||||
- [SMEMBERS key](#smembers-key)
|
||||
- [SREM key member [member ...]](#srem-key-member-member-)
|
||||
- [SUNION key [key ...]](#sunion-key-key-)
|
||||
- [SUNIONSTORE destination key [key ...]](#sunionstore-destination-key-key-)
|
||||
- [SCLEAR key](#sclear-key)
|
||||
- [SMCLEAR key [key...]](#smclear-key-key)
|
||||
- [SEXPIRE key seconds](#sexpire-key-seconds)
|
||||
- [SEXPIREAT key timestamp](#sexpireat-key-timestamp)
|
||||
- [STTL key](#sttl-key)
|
||||
- [SPERSIST key](#spersist-key)
|
||||
- [SDUMP key](#sdump-key)
|
||||
- [SADD key member [member ...]](#sadd-key-member-member-)
|
||||
- [SCARD key](#scard-key)
|
||||
- [SDIFF key [key ...]](#sdiff-key-key-)
|
||||
- [SDIFFSTORE destination key [key ...]](#sdiffstore-destination-key-key-)
|
||||
- [SINTER key [key ...]](#sinter-key-key-)
|
||||
- [SINTERSTORE destination key [key ...]](#sinterstore--destination-key-key-)
|
||||
- [SISMEMBER key member](#sismember--key-member)
|
||||
- [SMEMBERS key](#smembers-key)
|
||||
- [SREM key member [member ...]](#srem--key-member-member-)
|
||||
- [SUNION key [key ...]](#sunion-key-key-)
|
||||
- [SUNIONSTORE destination key [key]](#sunionstore-destination-key-key)
|
||||
- [SCLEAR key](#sclear-key)
|
||||
- [SMCLEAR key [key ...]](#smclear-key-key-)
|
||||
- [SEXPIRE key seconds](#sexpire-key-seconds)
|
||||
- [SEXPIREAT key timestamp](#sexpireat-key-timestamp)
|
||||
- [STTL key](#sttl-key)
|
||||
- [SPERSIST key](#spersist-key)
|
||||
- [SDUMP key](#sdump-key)
|
||||
- [ZSet](#zset)
|
||||
- [ZADD key score member [score member ...]](#zadd-key-score-member-score-member-)
|
||||
- [ZCARD key](#zcard-key)
|
||||
- [ZCOUNT key min max](#zcount-key-min-max)
|
||||
- [ZINCRBY key increment member](#zincrby-key-increment-member)
|
||||
- [ZRANGE key start stop [WITHSCORES]](#zrange-key-start-stop-withscores)
|
||||
- [ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]](#zrangebyscore-key-min-max-withscores-limit-offset-count)
|
||||
- [ZRANK key member](#zrank-key-member)
|
||||
- [ZREM key member [member ...]](#zrem-key-member-member-)
|
||||
- [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)
|
||||
- [ZREVRANK key member](#zrevrank-key-member)
|
||||
- [ZSCORE key member](#zscore-key-member)
|
||||
- [ZCLEAR key](#zclear-key)
|
||||
- [ZMCLEAR key [key ...]](#zmclear-key-key-)
|
||||
- [ZEXPIRE key seconds](#zexpire-key-seconds)
|
||||
- [ZEXPIREAT key timestamp](#zexpireat-key-timestamp)
|
||||
- [ZTTL key](#zttl-key)
|
||||
- [ZPERSIST key](#zpersist-key)
|
||||
- [ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]
|
||||
](#zunionstore-destination-numkeys-key-key--weights-weight-weight--aggregate-summinmax)
|
||||
- [ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]
|
||||
](#zinterstore-destination-numkeys-key-key--weights-weight-weight--aggregate-summinmax)
|
||||
- [ZRANGEBYLEX key min max [LIMIT offset count]](#zrangebylex-key-min-max-limit-offset-count)
|
||||
- [ZREMRANGEBYLEX key min max](#zremrangebylex-key-min-max)
|
||||
- [ZLEXCOUNT key min max](#zlexcount-key-min-max)
|
||||
- [ZDUMP key](#zdump-key)
|
||||
- [Bitmap](#bitmap)
|
||||
- [BGET key](#bget-key)
|
||||
- [BGETBIT key offset](#bgetbit-key-offset)
|
||||
- [BSETBIT key offset value](#bsetbit-key-offset-value)
|
||||
- [BMSETBIT key offset value[offset value ...]](#bmsetbit-key-offset-value-offset-value-)
|
||||
- [BOPT operation destkey key [key ...]](#bopt-operation-destkey-key-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)
|
||||
- [ZADD key score member [score member ...]](#zadd-key-score-member-score-member-)
|
||||
- [ZCARD key](#zcard-key)
|
||||
- [ZCOUNT key min max](#zcount-key-min-max)
|
||||
- [ZINCRBY key increment member](#zincrby-key-increment-member)
|
||||
- [ZRANGE key start stop [WITHSCORES]](#zrange-key-start-stop-withscores)
|
||||
- [ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]](#zrangebyscore-key-min-max-withscores-limit-offset-count)
|
||||
- [ZRANK key member](#zrank-key-member)
|
||||
- [ZREM key member [member ...]](#zrem-key-member-member-)
|
||||
- [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)
|
||||
- [ZREVRANK key member](#zrevrank-key-member)
|
||||
- [ZSCORE key member](#zscore-key-member)
|
||||
- [ZCLEAR key](#zclear-key)
|
||||
- [ZMCLEAR key [key ...]](#zmclear-key-key-)
|
||||
- [ZEXPIRE key seconds](#zexpire-key-seconds)
|
||||
- [ZEXPIREAT key timestamp](#zexpireat-key-timestamp)
|
||||
- [ZTTL key](#zttl-key)
|
||||
- [ZPERSIST key](#zpersist-key)
|
||||
- [ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]](#zunionstore-destination-numkeys-key-key--weights-weight-weight--aggregate-sum|min|max)
|
||||
- [ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]](#zinterstore-destination-numkeys-key-key--weights-weight-weight--aggregate-sum|min|max)
|
||||
- [ZRANGEBYLEX key min max [LIMIT offset count]](#zrangebylex-key-min-max-limit-offset-count)
|
||||
- [ZREMRANGEBYLEX key min max](#zremrangebylex-key-min-max)
|
||||
- [ZLEXCOUNT key min max](#zlexcount-key-min-max)
|
||||
- [ZDUMP key](#zdump-key)
|
||||
- [Scan](#scan)
|
||||
- [XSCAN type cursor [MATCH match] [COUNT count]](#xscan-type-cursor-match-match-count-count)
|
||||
- [XHSCAN key cursor [MATCH match] [COUNT count]](#xhscan-key-cursor-match-match-count-count)
|
||||
- [XSSCAN key cursor [MATCH match] [COUNT count]](#xsscan-key-cursor-match-match-count-count)
|
||||
- [XZSCAN key cursor [MATCH match] [COUNT count]](#xzscan-key-cursor-match-match-count-count)
|
||||
- [XSCAN type cursor [MATCH match] [COUNT count]](#xscan-type-cursor-match-match-count-count)
|
||||
- [XHSCAN key cursor [MATCH match] [COUNT count]](#xhscan-key-cursor-match-match-count-count)
|
||||
- [XSSCAN key cursor [MATCH match] [COUNT count]](#xsscan-key-cursor-match-match-count-count)
|
||||
- [XZSCAN key cursor [MATCH match] [COUNT count]](#xzscan-key-cursor-match-match-count-count)
|
||||
- [Replication](#replication)
|
||||
- [SLAVEOF host port [RESTART] [READONLY]](#slaveof-host-port-restart-readonly)
|
||||
- [FULLSYNC [NEW]](#fullsync-new)
|
||||
- [SYNC logid](#sync-logid)
|
||||
- [SLAVEOF host port [RESTART] [READONLY]](#slaveof-host-port-restart-readonly)
|
||||
- [FULLSYNC [NEW]](#fullsync-new)
|
||||
- [SYNC logid](#sync-logid)
|
||||
- [Server](#server)
|
||||
- [PING](#ping)
|
||||
- [ECHO message](#echo-message)
|
||||
- [SELECT index](#select-index)
|
||||
- [FLUSHALL](#flushall)
|
||||
- [FLUSHDB](#flushdb)
|
||||
- [INFO [section]](#info-section)
|
||||
- [TIME](#time)
|
||||
- [CONFIG REWRITE](#config-rewrite)
|
||||
- [RESTORE key ttl value](#restore-key-ttl-value)
|
||||
- [ROLE](#role)
|
||||
- [PING](#ping)
|
||||
- [ECHO message](#echo-message)
|
||||
- [SELECT index](#select-index)
|
||||
- [FLUSHALL](#flushall)
|
||||
- [FLUSHDB](#flushdb)
|
||||
- [INFO [section]](#info-section)
|
||||
- [TIME](#time)
|
||||
- [CONFIG REWRITE](#config-rewrite)
|
||||
- [RESTORE key ttl value](#restore-key-ttl-value)
|
||||
- [ROLE](#role)
|
||||
- [Transaction](#transaction)
|
||||
- [BEGIN](#begin)
|
||||
- [ROLLBACK](#rollback)
|
||||
- [COMMIT](#commit)
|
||||
- [BEGIN](#begin)
|
||||
- [ROLLBACK](#rollback)
|
||||
- [COMMIT](#commit)
|
||||
- [Script](#script)
|
||||
- [EVAL script numkeys key [key ...] arg [arg ...]](#eval-script-numkeys-key-key--arg-arg-)
|
||||
- [EVALSHA sha1 numkeys key [key ...] arg [arg ...]](#evalsha-sha1-numkeys-key-key--arg-arg-)
|
||||
- [SCRIPT LOAD script](#script-load-script)
|
||||
- [SCRIPT EXISTS script [script ...]](#script-exists-script-script-)
|
||||
- [SCRIPT FLUSH](#script-flush)
|
||||
- [EVAL script numkeys key [key ...] arg [arg ...]](#eval-script-numkeys-key-key--arg-arg-)
|
||||
- [EVALSHA sha1 numkeys key [key ...] arg [arg ...]](#evalsha-sha1-numkeys-key-key--arg-arg-)
|
||||
- [SCRIPT LOAD script](#script-load-script)
|
||||
- [SCRIPT EXISTS script [script ...]](#script-exists-script-script-)
|
||||
- [SCRIPT FLUSH](#script-flush)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
## KV
|
||||
|
||||
|
@ -524,6 +523,25 @@ ledis>DUMP mykey
|
|||
"\x00\xc0\n\x06\x00\xf8r?\xc5\xfb\xfb_("
|
||||
```
|
||||
|
||||
### APPEND key value
|
||||
|
||||
### GETRANGE key start end
|
||||
|
||||
### SETRANGE key offset value
|
||||
|
||||
### STRLEN key
|
||||
|
||||
### BITCOUNT key [start] [end]
|
||||
|
||||
### BITOP operation destkey key [key ...]
|
||||
|
||||
### BITPOS key bit [start] [end]
|
||||
|
||||
### GETBIT key offset
|
||||
|
||||
### SETBIT key offset value
|
||||
|
||||
|
||||
## Hash
|
||||
|
||||
### HDEL key field [field ...]
|
||||
|
@ -2332,164 +2350,6 @@ ledis> ZLEXCOUNT myzset - [c
|
|||
|
||||
See [DUMP](#dump-key) for more information.
|
||||
|
||||
## Bitmap
|
||||
|
||||
### 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**
|
||||
|
||||
```
|
||||
ledis> BMSETBIT flag 0 1 5 1 6 1
|
||||
(integer) 3
|
||||
ledis> BGET flag
|
||||
a
|
||||
```
|
||||
|
||||
|
||||
### 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
|
||||
```
|
||||
|
||||
|
||||
### 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
|
||||
```
|
||||
|
||||
### BMSETBIT key offset value [offset value ...]
|
||||
Sets the given *offset* to their respective values.
|
||||
|
||||
**Return value**
|
||||
|
||||
int64 : The number of input *offset*
|
||||
|
||||
**Examples**
|
||||
|
||||
```
|
||||
ledis> BMSETBIT flag 0 1 1 1 2 0 3 1
|
||||
(integer) 4
|
||||
ledis> BCOUNT flag
|
||||
(integer) 3
|
||||
```
|
||||
|
||||
|
||||
### BOPT operation destkey key [key ...]
|
||||
Perform a bitwise operation between multiple keys (containing string values) and store the result in the destination key.
|
||||
|
||||
**Return value**
|
||||
|
||||
Int64:
|
||||
The size of the string stored in the destination key, that is equal to the size of the longest input string.
|
||||
**Examples**
|
||||
|
||||
```
|
||||
ledis> BMSETBIT a 0 1 2 1
|
||||
(integer) 2
|
||||
ledis> BMSETBIT b 1 1
|
||||
(integer) 1
|
||||
ledis> BOPT AND res a b
|
||||
(integer) 3
|
||||
ledis> BCOUNT res
|
||||
(integer) 0
|
||||
ledis> BOPT OR res2 a b
|
||||
(integer) 3
|
||||
ledis> BCOUNT res2
|
||||
(integer) 3
|
||||
ledis> BOPT XOR res3 a b
|
||||
(integer) 3
|
||||
ledis> BCOUNT res3
|
||||
(integer) 3
|
||||
```
|
||||
|
||||
### BCOUNT key [start end]
|
||||
|
||||
Count the number of set bits in a bitmap.
|
||||
|
||||
**Return value**
|
||||
|
||||
int64 : The number of bits set to 1.
|
||||
|
||||
**Examples**
|
||||
|
||||
```
|
||||
ledis> BMSETBIT flag 0 1 5 1 6 1
|
||||
(integer) 3
|
||||
ledis> BGET flag
|
||||
a
|
||||
ledis> BCOUNT flag
|
||||
(integer) 3
|
||||
ledis> BCOUNT flag 0 0s
|
||||
(integer) 1
|
||||
ledis> BCOUNT flag 0 4
|
||||
(integer) 1
|
||||
ledis> BCOUNT flag 0 5
|
||||
(integer) 2
|
||||
ledis> BCOUNT flag 5 6
|
||||
(integer) 2
|
||||
```
|
||||
|
||||
|
||||
### BEXPIRE key seconds
|
||||
|
||||
(refer to [EXPIRE](#expire-key-seconds) api for other types)
|
||||
|
||||
|
||||
### BEXPIREAT key timestamp
|
||||
|
||||
(refer to [EXPIREAT](#expireat-key-timestamp) api for other types)
|
||||
|
||||
|
||||
### BTTL key
|
||||
|
||||
(refer to [TTL](#ttl-key) api for other types)
|
||||
|
||||
|
||||
### BPERSIST key
|
||||
|
||||
(refer to [PERSIST](#persist-key) api for other types)
|
||||
|
||||
|
||||
## Scan
|
||||
|
||||
### XSCAN type cursor [MATCH match] [COUNT count]
|
||||
|
|
|
@ -44,19 +44,19 @@ const (
|
|||
|
||||
// for backend store
|
||||
const (
|
||||
NoneType byte = 0
|
||||
KVType byte = 1
|
||||
HashType byte = 2
|
||||
HSizeType byte = 3
|
||||
ListType byte = 4
|
||||
LMetaType byte = 5
|
||||
ZSetType byte = 6
|
||||
ZSizeType byte = 7
|
||||
ZScoreType byte = 8
|
||||
BitType byte = 9
|
||||
BitMetaType byte = 10
|
||||
SetType byte = 11
|
||||
SSizeType byte = 12
|
||||
NoneType byte = 0
|
||||
KVType byte = 1
|
||||
HashType byte = 2
|
||||
HSizeType byte = 3
|
||||
ListType byte = 4
|
||||
LMetaType byte = 5
|
||||
ZSetType byte = 6
|
||||
ZSizeType byte = 7
|
||||
ZScoreType byte = 8
|
||||
// BitType byte = 9
|
||||
// BitMetaType byte = 10
|
||||
SetType byte = 11
|
||||
SSizeType byte = 12
|
||||
|
||||
maxDataType byte = 100
|
||||
|
||||
|
@ -73,16 +73,16 @@ const (
|
|||
|
||||
var (
|
||||
TypeName = map[byte]string{
|
||||
KVType: "kv",
|
||||
HashType: "hash",
|
||||
HSizeType: "hsize",
|
||||
ListType: "list",
|
||||
LMetaType: "lmeta",
|
||||
ZSetType: "zset",
|
||||
ZSizeType: "zsize",
|
||||
ZScoreType: "zscore",
|
||||
BitType: "bit",
|
||||
BitMetaType: "bitmeta",
|
||||
KVType: "kv",
|
||||
HashType: "hash",
|
||||
HSizeType: "hsize",
|
||||
ListType: "list",
|
||||
LMetaType: "lmeta",
|
||||
ZSetType: "zset",
|
||||
ZSizeType: "zsize",
|
||||
ZScoreType: "zscore",
|
||||
// BitType: "bit",
|
||||
// BitMetaType: "bitmeta",
|
||||
SetType: "set",
|
||||
SSizeType: "ssize",
|
||||
ExpTimeType: "exptime",
|
||||
|
|
|
@ -81,20 +81,20 @@ func formatEventKey(buf []byte, k []byte) ([]byte, error) {
|
|||
buf = append(buf, ' ')
|
||||
buf = strconv.AppendInt(buf, score, 10)
|
||||
}
|
||||
case BitType:
|
||||
if key, seq, err := db.bDecodeBinKey(k); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
buf = strconv.AppendQuote(buf, hack.String(key))
|
||||
buf = append(buf, ' ')
|
||||
buf = strconv.AppendUint(buf, uint64(seq), 10)
|
||||
}
|
||||
case BitMetaType:
|
||||
if key, err := db.bDecodeMetaKey(k); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
buf = strconv.AppendQuote(buf, hack.String(key))
|
||||
}
|
||||
// case BitType:
|
||||
// if key, seq, err := db.bDecodeBinKey(k); err != nil {
|
||||
// return nil, err
|
||||
// } else {
|
||||
// buf = strconv.AppendQuote(buf, hack.String(key))
|
||||
// buf = append(buf, ' ')
|
||||
// buf = strconv.AppendUint(buf, uint64(seq), 10)
|
||||
// }
|
||||
// case BitMetaType:
|
||||
// if key, err := db.bDecodeMetaKey(k); err != nil {
|
||||
// return nil, err
|
||||
// } else {
|
||||
// buf = strconv.AppendQuote(buf, hack.String(key))
|
||||
// }
|
||||
case SetType:
|
||||
if key, member, err := db.sDecodeSetKey(k); err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -174,7 +174,7 @@ func (l *Ledis) checkTTL() {
|
|||
c.register(ListType, db.listBatch, db.lDelete)
|
||||
c.register(HashType, db.hashBatch, db.hDelete)
|
||||
c.register(ZSetType, db.zsetBatch, db.zDelete)
|
||||
c.register(BitType, db.binBatch, db.bDelete)
|
||||
// c.register(BitType, db.binBatch, db.bDelete)
|
||||
c.register(SetType, db.setBatch, db.sDelete)
|
||||
|
||||
l.tcs[i] = c
|
||||
|
|
|
@ -36,8 +36,8 @@ type DB struct {
|
|||
listBatch *batch
|
||||
hashBatch *batch
|
||||
zsetBatch *batch
|
||||
binBatch *batch
|
||||
setBatch *batch
|
||||
// binBatch *batch
|
||||
setBatch *batch
|
||||
|
||||
status uint8
|
||||
|
||||
|
@ -60,7 +60,7 @@ func (l *Ledis) newDB(index uint8) *DB {
|
|||
d.listBatch = d.newBatch()
|
||||
d.hashBatch = d.newBatch()
|
||||
d.zsetBatch = d.newBatch()
|
||||
d.binBatch = d.newBatch()
|
||||
// d.binBatch = d.newBatch()
|
||||
d.setBatch = d.newBatch()
|
||||
|
||||
d.lbkeys = newLBlockKeys()
|
||||
|
@ -86,7 +86,6 @@ func (db *DB) FlushAll() (drop int64, err error) {
|
|||
db.lFlush,
|
||||
db.hFlush,
|
||||
db.zFlush,
|
||||
db.bFlush,
|
||||
db.sFlush}
|
||||
|
||||
for _, flush := range all {
|
||||
|
@ -117,9 +116,9 @@ func (db *DB) flushType(t *batch, dataType byte) (drop int64, err error) {
|
|||
case ZSetType:
|
||||
deleteFunc = db.zDelete
|
||||
metaDataType = ZSizeType
|
||||
case BitType:
|
||||
deleteFunc = db.bDelete
|
||||
metaDataType = BitMetaType
|
||||
// case BitType:
|
||||
// deleteFunc = db.bDelete
|
||||
// metaDataType = BitMetaType
|
||||
case SetType:
|
||||
deleteFunc = db.sDelete
|
||||
metaDataType = SSizeType
|
||||
|
|
|
@ -44,7 +44,7 @@ func (db *DB) Multi() (*Multi, error) {
|
|||
m.DB.listBatch = m.newBatch()
|
||||
m.DB.hashBatch = m.newBatch()
|
||||
m.DB.zsetBatch = m.newBatch()
|
||||
m.DB.binBatch = m.newBatch()
|
||||
// m.DB.binBatch = m.newBatch()
|
||||
m.DB.setBatch = m.newBatch()
|
||||
|
||||
m.DB.lbkeys = db.lbkeys
|
||||
|
|
|
@ -162,8 +162,8 @@ func (db *DB) encodeScanKey(storeDataType byte, key []byte) ([]byte, error) {
|
|||
return db.zEncodeSizeKey(key), nil
|
||||
case SSizeType:
|
||||
return db.sEncodeSizeKey(key), nil
|
||||
case BitMetaType:
|
||||
return db.bEncodeMetaKey(key), nil
|
||||
// case BitMetaType:
|
||||
// return db.bEncodeMetaKey(key), nil
|
||||
default:
|
||||
return nil, errDataType
|
||||
}
|
||||
|
|
1742
ledis/t_bit.go
1742
ledis/t_bit.go
File diff suppressed because it is too large
Load Diff
|
@ -58,7 +58,6 @@ func (db *DB) Begin() (*Tx, error) {
|
|||
tx.DB.listBatch = tx.newBatch()
|
||||
tx.DB.hashBatch = tx.newBatch()
|
||||
tx.DB.zsetBatch = tx.newBatch()
|
||||
tx.DB.binBatch = tx.newBatch()
|
||||
tx.DB.setBatch = tx.newBatch()
|
||||
|
||||
tx.DB.lbkeys = db.lbkeys
|
||||
|
|
|
@ -1,289 +1,289 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"github.com/siddontang/go/hack"
|
||||
// import (
|
||||
// "github.com/siddontang/go/hack"
|
||||
|
||||
"github.com/siddontang/ledisdb/ledis"
|
||||
"strings"
|
||||
)
|
||||
// "github.com/siddontang/ledisdb/ledis"
|
||||
// "strings"
|
||||
// )
|
||||
|
||||
func bgetCommand(c *client) error {
|
||||
args := c.args
|
||||
if len(args) != 1 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// func bgetCommand(c *client) error {
|
||||
// args := c.args
|
||||
// if len(args) != 1 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
if v, err := c.db.BGet(args[0]); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeBulk(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// if v, err := c.db.BGet(args[0]); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeBulk(v)
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func bdeleteCommand(c *client) error {
|
||||
args := c.args
|
||||
if len(args) != 1 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// func bdeleteCommand(c *client) error {
|
||||
// args := c.args
|
||||
// if len(args) != 1 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
if n, err := c.db.BDelete(args[0]); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeInteger(n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// if n, err := c.db.BDelete(args[0]); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeInteger(n)
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func bsetbitCommand(c *client) error {
|
||||
args := c.args
|
||||
if len(args) != 3 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// func bsetbitCommand(c *client) error {
|
||||
// args := c.args
|
||||
// if len(args) != 3 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
var err error
|
||||
var offset int32
|
||||
var val int8
|
||||
// var err error
|
||||
// var offset int32
|
||||
// var val int8
|
||||
|
||||
offset, err = ledis.StrInt32(args[1], nil)
|
||||
// offset, err = ledis.StrInt32(args[1], nil)
|
||||
|
||||
if err != nil {
|
||||
return ErrOffset
|
||||
}
|
||||
// if err != nil {
|
||||
// return ErrOffset
|
||||
// }
|
||||
|
||||
val, err = ledis.StrInt8(args[2], nil)
|
||||
if val != 0 && val != 1 {
|
||||
return ErrBool
|
||||
}
|
||||
// val, err = ledis.StrInt8(args[2], nil)
|
||||
// if val != 0 && val != 1 {
|
||||
// return ErrBool
|
||||
// }
|
||||
|
||||
if err != nil {
|
||||
return ErrBool
|
||||
}
|
||||
// if err != nil {
|
||||
// return ErrBool
|
||||
// }
|
||||
|
||||
if ori, err := c.db.BSetBit(args[0], offset, uint8(val)); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeInteger(int64(ori))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// if ori, err := c.db.BSetBit(args[0], offset, uint8(val)); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeInteger(int64(ori))
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func bgetbitCommand(c *client) error {
|
||||
args := c.args
|
||||
if len(args) != 2 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// func bgetbitCommand(c *client) error {
|
||||
// args := c.args
|
||||
// if len(args) != 2 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
offset, err := ledis.StrInt32(args[1], nil)
|
||||
// offset, err := ledis.StrInt32(args[1], nil)
|
||||
|
||||
if err != nil {
|
||||
return ErrOffset
|
||||
}
|
||||
// if err != nil {
|
||||
// return ErrOffset
|
||||
// }
|
||||
|
||||
if v, err := c.db.BGetBit(args[0], offset); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeInteger(int64(v))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// if v, err := c.db.BGetBit(args[0], offset); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeInteger(int64(v))
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func bmsetbitCommand(c *client) error {
|
||||
args := c.args
|
||||
if len(args) < 3 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// func bmsetbitCommand(c *client) error {
|
||||
// args := c.args
|
||||
// if len(args) < 3 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
key := args[0]
|
||||
if len(args[1:])&1 != 0 {
|
||||
return ErrCmdParams
|
||||
} else {
|
||||
args = args[1:]
|
||||
}
|
||||
// key := args[0]
|
||||
// if len(args[1:])&1 != 0 {
|
||||
// return ErrCmdParams
|
||||
// } else {
|
||||
// args = args[1:]
|
||||
// }
|
||||
|
||||
var err error
|
||||
var offset int32
|
||||
var val int8
|
||||
// var err error
|
||||
// var offset int32
|
||||
// var val int8
|
||||
|
||||
pairs := make([]ledis.BitPair, len(args)>>1)
|
||||
for i := 0; i < len(pairs); i++ {
|
||||
offset, err = ledis.StrInt32(args[i<<1], nil)
|
||||
// pairs := make([]ledis.BitPair, len(args)>>1)
|
||||
// for i := 0; i < len(pairs); i++ {
|
||||
// offset, err = ledis.StrInt32(args[i<<1], nil)
|
||||
|
||||
if err != nil {
|
||||
return ErrOffset
|
||||
}
|
||||
// if err != nil {
|
||||
// return ErrOffset
|
||||
// }
|
||||
|
||||
val, err = ledis.StrInt8(args[i<<1+1], nil)
|
||||
if val != 0 && val != 1 {
|
||||
return ErrBool
|
||||
}
|
||||
// val, err = ledis.StrInt8(args[i<<1+1], nil)
|
||||
// if val != 0 && val != 1 {
|
||||
// return ErrBool
|
||||
// }
|
||||
|
||||
if err != nil {
|
||||
return ErrBool
|
||||
}
|
||||
// if err != nil {
|
||||
// return ErrBool
|
||||
// }
|
||||
|
||||
pairs[i].Pos = offset
|
||||
pairs[i].Val = uint8(val)
|
||||
}
|
||||
// pairs[i].Pos = offset
|
||||
// pairs[i].Val = uint8(val)
|
||||
// }
|
||||
|
||||
if place, err := c.db.BMSetBit(key, pairs...); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeInteger(place)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// if place, err := c.db.BMSetBit(key, pairs...); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeInteger(place)
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func bcountCommand(c *client) error {
|
||||
args := c.args
|
||||
argCnt := len(args)
|
||||
// func bcountCommand(c *client) error {
|
||||
// args := c.args
|
||||
// argCnt := len(args)
|
||||
|
||||
if !(argCnt > 0 && argCnt <= 3) {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// if !(argCnt > 0 && argCnt <= 3) {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
// BCount(key []byte, start int32, end int32) (cnt int32, err error) {
|
||||
// // BCount(key []byte, start int32, end int32) (cnt int32, err error) {
|
||||
|
||||
var err error
|
||||
var start, end int32 = 0, -1
|
||||
// var err error
|
||||
// var start, end int32 = 0, -1
|
||||
|
||||
if argCnt > 1 {
|
||||
start, err = ledis.StrInt32(args[1], nil)
|
||||
if err != nil {
|
||||
return ErrValue
|
||||
}
|
||||
}
|
||||
// if argCnt > 1 {
|
||||
// start, err = ledis.StrInt32(args[1], nil)
|
||||
// if err != nil {
|
||||
// return ErrValue
|
||||
// }
|
||||
// }
|
||||
|
||||
if argCnt > 2 {
|
||||
end, err = ledis.StrInt32(args[2], nil)
|
||||
if err != nil {
|
||||
return ErrValue
|
||||
}
|
||||
}
|
||||
// if argCnt > 2 {
|
||||
// end, err = ledis.StrInt32(args[2], nil)
|
||||
// if err != nil {
|
||||
// return ErrValue
|
||||
// }
|
||||
// }
|
||||
|
||||
if cnt, err := c.db.BCount(args[0], start, end); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeInteger(int64(cnt))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// if cnt, err := c.db.BCount(args[0], start, end); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeInteger(int64(cnt))
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func boptCommand(c *client) error {
|
||||
args := c.args
|
||||
if len(args) < 2 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// func boptCommand(c *client) error {
|
||||
// args := c.args
|
||||
// if len(args) < 2 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
opDesc := strings.ToLower(hack.String(args[0]))
|
||||
dstKey := args[1]
|
||||
srcKeys := args[2:]
|
||||
// opDesc := strings.ToLower(hack.String(args[0]))
|
||||
// dstKey := args[1]
|
||||
// srcKeys := args[2:]
|
||||
|
||||
var op uint8
|
||||
switch opDesc {
|
||||
case "and":
|
||||
op = ledis.OPand
|
||||
case "or":
|
||||
op = ledis.OPor
|
||||
case "xor":
|
||||
op = ledis.OPxor
|
||||
case "not":
|
||||
op = ledis.OPnot
|
||||
default:
|
||||
return ErrCmdParams
|
||||
}
|
||||
// var op uint8
|
||||
// switch opDesc {
|
||||
// case "and":
|
||||
// op = ledis.OPand
|
||||
// case "or":
|
||||
// op = ledis.OPor
|
||||
// case "xor":
|
||||
// op = ledis.OPxor
|
||||
// case "not":
|
||||
// op = ledis.OPnot
|
||||
// default:
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
if len(srcKeys) == 0 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
if blen, err := c.db.BOperation(op, dstKey, srcKeys...); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeInteger(int64(blen))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// if len(srcKeys) == 0 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
// if blen, err := c.db.BOperation(op, dstKey, srcKeys...); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeInteger(int64(blen))
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func bexpireCommand(c *client) error {
|
||||
args := c.args
|
||||
if len(args) != 2 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// func bexpireCommand(c *client) error {
|
||||
// args := c.args
|
||||
// if len(args) != 2 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
duration, err := ledis.StrInt64(args[1], nil)
|
||||
if err != nil {
|
||||
return ErrValue
|
||||
}
|
||||
// duration, err := ledis.StrInt64(args[1], nil)
|
||||
// if err != nil {
|
||||
// return ErrValue
|
||||
// }
|
||||
|
||||
if v, err := c.db.BExpire(args[0], duration); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeInteger(v)
|
||||
}
|
||||
// if v, err := c.db.BExpire(args[0], duration); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeInteger(v)
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func bexpireAtCommand(c *client) error {
|
||||
args := c.args
|
||||
if len(args) != 2 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// func bexpireAtCommand(c *client) error {
|
||||
// args := c.args
|
||||
// if len(args) != 2 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
when, err := ledis.StrInt64(args[1], nil)
|
||||
if err != nil {
|
||||
return ErrValue
|
||||
}
|
||||
// when, err := ledis.StrInt64(args[1], nil)
|
||||
// if err != nil {
|
||||
// return ErrValue
|
||||
// }
|
||||
|
||||
if v, err := c.db.BExpireAt(args[0], when); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeInteger(v)
|
||||
}
|
||||
// if v, err := c.db.BExpireAt(args[0], when); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeInteger(v)
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func bttlCommand(c *client) error {
|
||||
args := c.args
|
||||
if len(args) != 1 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// func bttlCommand(c *client) error {
|
||||
// args := c.args
|
||||
// if len(args) != 1 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
if v, err := c.db.BTTL(args[0]); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeInteger(v)
|
||||
}
|
||||
// if v, err := c.db.BTTL(args[0]); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeInteger(v)
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func bpersistCommand(c *client) error {
|
||||
args := c.args
|
||||
if len(args) != 1 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
// func bpersistCommand(c *client) error {
|
||||
// args := c.args
|
||||
// if len(args) != 1 {
|
||||
// return ErrCmdParams
|
||||
// }
|
||||
|
||||
if n, err := c.db.BPersist(args[0]); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeInteger(n)
|
||||
}
|
||||
// if n, err := c.db.BPersist(args[0]); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// c.resp.writeInteger(n)
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func init() {
|
||||
register("bget", bgetCommand)
|
||||
register("bdelete", bdeleteCommand)
|
||||
register("bsetbit", bsetbitCommand)
|
||||
register("bgetbit", bgetbitCommand)
|
||||
register("bmsetbit", bmsetbitCommand)
|
||||
register("bcount", bcountCommand)
|
||||
register("bopt", boptCommand)
|
||||
register("bexpire", bexpireCommand)
|
||||
register("bexpireat", bexpireAtCommand)
|
||||
register("bttl", bttlCommand)
|
||||
register("bpersist", bpersistCommand)
|
||||
}
|
||||
// func init() {
|
||||
// register("bget", bgetCommand)
|
||||
// register("bdelete", bdeleteCommand)
|
||||
// register("bsetbit", bsetbitCommand)
|
||||
// register("bgetbit", bgetbitCommand)
|
||||
// register("bmsetbit", bmsetbitCommand)
|
||||
// register("bcount", bcountCommand)
|
||||
// register("bopt", boptCommand)
|
||||
// register("bexpire", bexpireCommand)
|
||||
// register("bexpireat", bexpireAtCommand)
|
||||
// register("bttl", bttlCommand)
|
||||
// register("bpersist", bpersistCommand)
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue