Add slot based connection which routes requests according to key slot

This commit is contained in:
Marcos Nils
2013-12-28 00:59:35 -03:00
parent 9f767a0848
commit b2d22e2060
6 changed files with 186 additions and 136 deletions

View File

@@ -14,7 +14,7 @@ public class JedisRandomConnectionHandler extends JedisClusterConnectionHandler
@SuppressWarnings("unchecked")
public Jedis getConnection() {
public Jedis getConnection(String key) {
Object[] nodeArray = nodes.values().toArray();
return ((Pool<Jedis>) nodeArray[new Random().nextInt(nodeArray.length)]).getResource();
}