Redis分片API:redis-shard

jopen 12年前

redis-shard 是 Redis 分片的 Python API ,基于对 key 和 key tag 进行 CRC32 checksum 计算,可参考文章 http://antirez.com/post/redis-presharding.html . 该项目由知乎网开发。示例代码:

>>> 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)

项目主页:http://www.open-open.com/lib/view/home/1351061647258