ShardedJedis實現分析
ShardedJedis是基於一致性哈希算法實現的分布式Redis集群客戶端;ShardedJedis的設計分為以下幾塊:
1.對象池設計:Pool,ShardedJedisPool,ShardedJedisFactory
2.面向用戶的操作封裝:BinaryShardedJedis,BinaryShardedJedis
3.一致性哈希實現:Sharded
關於ShardedJedis設計,忽略了Jedis的設計細節,設計類圖如下:
代碼實現:
model對象:
package com.duobei.memcached.model;
import java.io.Serializable;
public class User implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String pass;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
}