tid
项目repo地址 https://github.com/yongman/tidis
Tidis是分布式数据库,支持redis协议,多种数据结构支持,编写语言为golang。
Tidis工作角色类似于TIDB,提供协议转换和数据结构计算,底层使用TiKV分布式kv存储引擎,采用raft数据复制的数据高可用和两阶段提交实现的分布式事务。
特点:
- redis协议兼容
- 集群规模线性扩展
- 计算与存储分离
- 分布式事务支持
- 数据安全,raft复制,数据保证不丢失
编译:
git clone https://github.com/yongman/tidis.git
make
运行tikv集群:
参考pingcap官方教程https://github.com/pingcap/docs/blob/master/op-guide/docker-deployment.md
运行tidis:
bin/bin/tidis-server -backend <pd address, ip:port>
redis-cli -p 5379
127.0.0.1:5379> get a
"1"
127.0.0.1:5379> lrange l 0 -1
1) "6"
2) "5"
3) "4"
127.0.0.1:5379> zadd zzz 1 1 2 2 3 3 4 4
(integer) 4
127.0.0.1:5379> zcard zzz
(integer) 4
127.0.0.1:5379> zincrby zzz 10 1
(integer) 11
127.0.0.1:5379> zrange zzz 0 -1 withscores
1) "2"
2) "2"
3) "3"
4) "3"
5) "4"
6) "4"
7) "1"
8) "11"
支持命令:
string
+-----------+----------------------------------+
| command | format |
+-----------+----------------------------------+
| get | get key |
+-----------+----------------------------------+
| set | set key value |
+-----------+----------------------------------+
| del | del key1 key2 ... |
+-----------+----------------------------------+
| mget | mget key1 key2 ... |
+-----------+----------------------------------+
| mset | mset key1 value1 key2 value2 ... |
+-----------+----------------------------------+
| incr | incr key |
+-----------+----------------------------------+
| incrby | incr key step |
+-----------+----------------------------------+
| decr | decr key |
+-----------+----------------------------------+
| decrby | decrby key step |
+-----------+----------------------------------+
| strlen | strlen key |
+-----------+----------------------------------+
| pexpire | pexpire key int |
+-----------+----------------------------------+
| pexpireat | pexpireat key timestamp(ms) |
+-----------+----------------------------------+
| expire | expire key int |
+-----------+----------------------------------+
| expireat | expireat key timestamp(s) |
+-----------+----------------------------------+
| pttl | pttl key |
+-----------+----------------------------------+
| ttl | ttl key |
+-----------+----------------------------------+
hash
+------------+------------------------------------------+
| Commands | Format |
+------------+------------------------------------------+
| hget | hget key field |
+------------+------------------------------------------+
| hstrlen | hstrlen key |
+------------+------------------------------------------+
| hexists | hexists key |
+------------+------------------------------------------+
| hlen | hlen key |
+------------+------------------------------------------+
| hmget | hmget key field1 field2 field3... |
+------------+------------------------------------------+
| hdel | hdel key field1 field2 field3... |
+------------+------------------------------------------+
| hset | hset key field value |
+------------+------------------------------------------+
| hsetnx | hsetnx key field value |
+------------+------------------------------------------+
| hmset | hmset key field1 value1 field2 value2... |
+------------+------------------------------------------+
| hkeys | hkeys key |
+------------+------------------------------------------+
| hvals | hvals key |
+------------+------------------------------------------+
| hgetall | hgetall key |
+------------+------------------------------------------+
| hclear | hclear key |
+------------+------------------------------------------+
| hpexpire | hpexpire key int |
+------------+------------------------------------------+
| hpexpireat | hpexpireat key ts |
+------------+------------------------------------------+
| hexpire | hexpire key int |
+------------+------------------------------------------+
| hexpireat | hexpireat key ts |
+------------+------------------------------------------+
| hpttl | hpttl key |
+------------+------------------------------------------+
| httl | httl key |
+------------+------------------------------------------+
list
+------------+-----------------------+
| commands | format |
+------------+-----------------------+
| lpop | lpop key |
+------------+-----------------------+
| rpush | rpush key |
+------------+-----------------------+
| rpop | rpop key |
+------------+-----------------------+
| llen | llen key |
+------------+-----------------------+
| lindex | lindex key index |
+------------+-----------------------+
| lrange | lrange key start stop |
+------------+-----------------------+
| lset | lset key index value |
+------------+-----------------------+
| ltrim | ltrim key start stop |
+------------+-----------------------+
| ldel | ldel key |
+------------+-----------------------+
| lpexipre | lpexpire key int |
+------------+-----------------------+
| lpexipreat | lpexpireat key ts |
+------------+-----------------------+
| lexpire | lexpire key int |
+------------+-----------------------+
| lexpireat | lexpireat key ts |
+------------+-----------------------+
| lpttl | lpttl key |
+------------+-----------------------+
| lttl | lttl key |
+------------+-----------------------+
set
+-------------+--------------------------------+
| commands | format |
+-------------+--------------------------------+
| sadd | sadd key member1 [member2 ...] |
+-------------+--------------------------------+
| scard | scard key |
+-------------+--------------------------------+
| sismember | sismember key member |
+-------------+--------------------------------+
| smembers | smembers key |
+-------------+--------------------------------+
| srem | srem key member |
+-------------+--------------------------------+
| sdiff | sdiff key1 key2 |
+-------------+--------------------------------+
| sunion | sunion key1 key2 |
+-------------+--------------------------------+
| sinter | sinter key1 key2 |
+-------------+--------------------------------+
| sdiffstore | sdiffstore key1 key2 key3 |
+-------------+--------------------------------+
| sunionstore | sunionstore key1 key2 key3 |
+-------------+--------------------------------+
| sinterstore | sinterstore key1 key2 key3 |
+-------------+--------------------------------+
| sclear | sclear key |
+-------------+--------------------------------+
| spexpire | spexpire key int |
+-------------+--------------------------------+
| spexpireat | spexpireat key ts |
+-------------+--------------------------------+
| sexpire | sexpire key int |
+-------------+--------------------------------+
| sexpireat | sexpireat key ts |
+-------------+--------------------------------+
| spttl | spttl key |
+-------------+--------------------------------+
| sttl | sttl key |
+-------------+--------------------------------+
sorted set
+------------------+---------------------------------------------------------------+
| commands | format |
+------------------+---------------------------------------------------------------+
| zadd | zadd key member1 score1 [member2 score2 ...] |
+------------------+---------------------------------------------------------------+
| zcard | zcard key |
+------------------+---------------------------------------------------------------+
| zrange | zrange key start stop [WITHSCORES] |
+------------------+---------------------------------------------------------------+
| zrevrange | zrevrange key start stop [WITHSCORES] |
+------------------+---------------------------------------------------------------+
| zrangebyscore | zrangebyscore key min max [WITHSCORES][limit offset count] |
+------------------+---------------------------------------------------------------+
| zrevrangebyscore | zrevrangebyscore key max min [WITHSCORES][LIMIT offset count] |
+------------------+---------------------------------------------------------------+
| zremrangebyscore | zremrangebyscore key min max |
+------------------+---------------------------------------------------------------+
| zrangebylex | zrangebylex key min max [LIMIT offset count] |
+------------------+---------------------------------------------------------------+
| zrevrangebylex | zrevrangebylex key max min [LIMIT offset count] |
+------------------+---------------------------------------------------------------+
| zremrangebylex | zremrangebylex key min max |
+------------------+---------------------------------------------------------------+
| zcount | zcount key |
+------------------+---------------------------------------------------------------+
| zlexcount | zlexcount key |
+------------------+---------------------------------------------------------------+
| zscore | zscore key member |
+------------------+---------------------------------------------------------------+
| zrem | zrem key member1 [member2 ...] |
+------------------+---------------------------------------------------------------+
| zclear | zclear key |
+------------------+---------------------------------------------------------------+
| zincrby | zincrby key increment member |
+------------------+---------------------------------------------------------------+
| zpexpire | zpexpire key int |
+------------------+---------------------------------------------------------------+
| zpexpireat | zpexpireat key ts |
+------------------+---------------------------------------------------------------+
| zexpire | zexpire key int |
+------------------+---------------------------------------------------------------+
| zexpireat | zexpireat key ts |
+------------------+---------------------------------------------------------------+
| zpttl | zpttl key |
+------------------+---------------------------------------------------------------+
| zttl | zttl key |
+------------------+---------------------------------------------------------------+
transaction
+---------+---------+
| command | support |
+---------+---------+
| multi | Yes |
+---------+---------+
| exec | Yes |
+---------+---------+
基础性能数据:
https://github.com/yongman/tidis/wiki/Tidis-base-benchmark
参考:
https://xiking.win/2018/07/17/tidis-distributed-transactional-redis-protocol-disk-storage/
相关阅读
Redis+TwemProxy(nutcracker)集群方案部署记录
Twemproxy 又称nutcracker ,是一个memcache、Redis协议的轻量级代理,一个用于sharding 的中间件。有了Twemproxy,客户端不直接访问Re
redis-cluster槽道的原理: 本文配图是为了便于理解,如果图片影响了您的阅读,翻到博客末尾,笔者copy了无图版 1 redis服务如何判
Redis官网推荐使用Linux安装redis。所以Linux安装redis来说超级简单。只需一行命令既可。这里就不做过多的解释。 一、首先下载re