项目repo地址 GitHub - yongman/tidis: Distributed transactional NoSQL database, Redis protocol compatible using tikv as backend
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 |
+-----------+--------------------