Spring集成Redis实例入门

ShardedJedis实现分析

ShardedJedis是基于一致性哈希算法实现的分布式Redis集群客户端;ShardedJedis的设计分为以下几块:

1.对象池设计:Pool,ShardedJedisPool,ShardedJedisFactory

2.面向用户的操作封装:BinaryShardedJedis,BinaryShardedJedis

3.一致性哈希实现:Sharded

关于ShardedJedis设计,忽略了Jedis的设计细节,设计类图如下:

Spring集成Redis实例入门

代码实现:

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;
 }

}

相关推荐