LiteKV is a simple key-value storage implementation.
mkdir build
cd build
cmake ..
make- integer
- string
- list
- hash
- set
- Pub/Sub
- AOF
- LiteKV Binary Format
| Type | Command | Usage | Description |
|---|---|---|---|
| Generic | |||
| ping | ping | Ping the server | |
| del | del key [key...] | Remove the specified keys | |
| exists | exists key [key...] | Return if specified keys exist | |
| type | type key | Return data type of specified key | |
| expire | expire key seconds | Set expiration for key | |
| expireat | expireat key unix-timestamp | Set key expire in unix-timestamp | |
| ttl | ttl key | Get the time to live (TTL) in seconds of key | |
| Integer or String | |||
| set | set key value | Set key to store string or integer value | |
| get | get key | Get the value of key | |
| Integer | |||
| incr | incr key | Increase int value by 1 on given key | |
| decr | decr key | Decrease int value by 1 on given key | |
| incrby | incrby key value | Increase int value by n on given key | |
| decrby | decry key value | Decrease int value by n on given key | |
| String | |||
| strlen | strlen key | Return the length of value at key | |
| append | append key value | Append value to existing value at key | |
| List | |||
| llen | llen key | Return the size of list at key | |
| lpop | lpop key | Remove and return the first item of list at key | |
| lpush | lpush key value [value...] | Insert all values at the head of list at key | |
| rpop | rpop key | Remove and return the last item of list at key | |
| rpush | rpush key value [value...] | Insert all values at the end of list at key | |
| lrange | lrange key begin end | Return all items in specified range of list at key | |
| lsetindex | lsetindex key index value | Set the item to value at index. | |
| lindex | lindex key index | Return the item at index | |
| Hash | |||
| hset | hset key field value [field value...] | Set field-value pair in hash at key | |
| hget | hget key field [field...] | Get values of fields in hash at key | |
| hdel | hdel key field [field...] | Remove fields in hash at key | |
| hexists | hexists key field | Check the existence of field in hash at key | |
| hgetall | hgetall key | Return all field-value pairs in hash at key | |
| hkeys | hkeys key | Return all fields in hash at key | |
| hvals | hvals key | Return all values in hash at key | |
| hlen | hlen key | Return the number of pairs in hash at key | |
| Set | |||
| sadd | sadd key member [member...] | Add members into set at key | |
| sismember | sismember key member | Check a member is inside set at key | |
| smismember | smismember key member [member...] | Check multiple members are inside set at key | |
| smembers | smembers key | Return all members inside set at key | |
| srem | srem key member [member...] | Remove the specified members inside set at key | |
| scard | scard key | Return the number of members inside set at key | |
| Pub/Sub | |||
| publish | publish chan msg | Publish a message to specific channel | |
| subscribe | subscribe chan1 [chan2...] | Subscribe to specific channels | |
| unsubscribe | unsubscribe chan1 [chan2...] | Unsubscribe from specific channels |
Since our communication protocol is based on RESP, the redis-benchmark tool from redis can be used to benchmark this repository.
The following command is used for benchmarking. We make N_CLIENTS and N_THREADS as two variables;
redis-benchmark -h 127.0.0.1 -p 9527 \
-c $N_CLIENTS \
-n 100000 \
-t set,get,incr,lpush,rpush,lpop,rpop,lrange,hset \
--threads $N_THREADS \
-r 10000 \
--csvMachine: 64bit AMD 3600 CPU + 16G RAM
System: Ubuntu 16.04
Compiler: gcc 5.4.0
redis-benchmark version: 7.0.2
- Performance Optimization
- string object optimization (COW or SSO)
- dlist optimization (redesign and reconstruct)
- Features
- support more data structure, such as
set, sorted sets, etc. - transaction
- make it distributed
- master-slave mode
pub/sub mode- sentinel
- use connection pool
- support more data structure, such as



