ServiceStack/ServiceStack.Redis — pull request #59 by kumarnitin (2012-07-03 06:42:34+00:00)
Title: Support for Consistent Hashing

Example :

var PoolA = new ShardedConnectionPool("PoolA", 1, "192.168.1.204:6379");
var PoolB = new ShardedConnectionPool("PoolB", 1, "192.168.1.204:6381");
var sharedClientManager = new ShardedRedisClientManager(PoolA, PoolB);

// add keys
for (int i = 0; i < 10000; i++)
{
var clientManager = sharedClientManager.GetConnectionPool(i.ToString());
using (var redis = clientManager.GetClient())
{
redis.Set(i.ToString(), i.ToString());
}
}

// test keys are found and correctly set across the two redis servers
for (int i = 0; i < 10000; i++)
{
var clientManager = sharedClientManager.GetConnectionPool(i.ToString());
using (var redis = clientManager.GetClient())
{
var val = redis.Get(i.ToString());
Debug.Assert(val == i.ToString());
}
}