Skip to main content

Redis Sharding API

Project description

Redis Shard

A redis sharding api. Sharding is done based on the CRC32 checksum of a key or key tag (“key{key_tag}”), according to this article http://antirez.com/post/redis-presharding.html .

Useage

Creating a hash ring with multiple servers,By default the hash ring uses a crc32 hashing algorithm on the server’s name config.You can define the name anything as you like,but it must be unique.

I don’t want to bind the hashring with ipaddress,because if I do some master/slave switches, I can only change the ipaddress related config. The name is kept,so the hashring’s order is kept.

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

Hash tags

see article http://antirez.com/post/redis-presharding.html for detail.

>>> client.set('foo',2)
>>> client.set('a{foo}',5)
>>> client.set('b{foo}',5)
>>> client.set('c{foo}',5)

Change History

0.1.2 (2011-06-01)

add MANIFEST.in file

0.1.1 (2011-05-29)

create hashring use server’s name config.

0.1 (2011-05-28)

first version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redis-shard-0.1.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redis_shard-0.1.2-py2.6.egg (7.6 kB view details)

Uploaded Egg

File details

Details for the file redis-shard-0.1.2.tar.gz.

File metadata

  • Download URL: redis-shard-0.1.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for redis-shard-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2a4850173f31c47b37e83550b1fa65f4c619cc908b94e038a628fc29b3b55ad6
MD5 b917f86ef933d1d2c1516d49eda0bb97
BLAKE2b-256 56f9c8b99959d84df8ff72a2b5fe339f017dd392dc7ed79b696ae7b32ce7bae5

See more details on using hashes here.

File details

Details for the file redis_shard-0.1.2-py2.6.egg.

File metadata

File hashes

Hashes for redis_shard-0.1.2-py2.6.egg
Algorithm Hash digest
SHA256 65d381cdf392f4501f61838975c6d2276950015608729f5b3f62255a636cfaba
MD5 837db66815a9ef469b754ffaf82f169c
BLAKE2b-256 90a3b28838da42f1a05200335c5a19c017d9a7742a6d733ca3d1250d61398ced

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page