redis-shard是Redis分区的PythonAPI,基于对key和keytag进行CRC32checksum计算,可参考文章https://antirez.com/post/redis-presharding.html.该项目由知乎网开发。
使用限制:
RedisShard不支持所有Redis命令
不支持多键命令行跨不同的节点,你可以使用HashTag
RedisShard不提供复制机制
示例代码:
>>> from redis_shard.shard import RedisShardAPI>>> servers = [ ... {'name':'server1','host':'127.0.0.1','port':10000,'db':0}, ... {'name':'server2','host':'127.0.0.1','port':11000,'db':0}, ... {'name':'server3','host':'127.0.0.1','port':12000,'db':0}, ... {'name':'127.0.0.1:13000','host':'127.0.0.1','port':13000,'db':0}, ... ]>>>>>> client = RedisShardAPI(servers)>>> client.set('test',1)>>> print client.get('test')>>> client.zadd('testset','first',1)>>> client.zadd('testset','second',2)>>> print client.zrange('testset',0,-1)
评论