1 Star 0 Fork 2

Fourwenwen / spring-consistent-hash

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
Fourwenwen 提交于 2017-06-22 18:41 . 添加使用说明

基于Spring的一致性hash缓存插件

wen icon

核心功能已经完成,但是会持续更新的。 功能简陋,代码难看,多多谅解。任意的意见和建议,欢迎随意与我沟通。 项目的Bug和改进点,可在OSChina上以issue的方式直接提交给我。

#ConsistentHash 写这个东西是为了实现一致性hash来控制redis集群.

#项目结构 spring-consistent-hash-cache 基于spring的一致性hash的redis集群方案的jar包。依赖进去项目,根据订制规则配置就可以使用。 spring-boot-example 使用spring-consistent-hash-cache的spring boot例子 spring-mvc-example 使用spring-consistent-hash-cache的spring mvc例子

需要知识点

  • 基于spring开发的
  • spring cache,基于注释的cache技术,它本质上不是一个具体的缓存实现方案,而是一个对缓存使用的抽象。
  • redis,key-value存储系统。
  • 一致性哈希算法,可自行去问度娘。

配置说明

必须在项目resources目录下放置ch-cache.properties文件。 ####redis服务器数量 -redis.count=2 ####redis服务器0配置 -redis.host0=192.168.0.1 -redis.port0=6379 -reids.passwd0=test -redis.db.size0=16 ####redis服务器1配置 -redis.host1=192.168.0.2 -redis.port1=6380 -reids.passwd1=test -redis.db.size1=16

使用方法(简单说明)

  1. maven导入项目包
win.pangniu.four spring-consistent-hash-cache 1.0-SNAPSHOT
  1. 在项目resources文件加中添加ch-cache.properties文件。配置内容细看配置说明

  2. 在项目中进行配置

    • Spring boot项目 参考spring-boot-example项目中的配置,细看CacheConfig.class。
    • Spring mvc项目 参考spring-mvc-example项目中的配置,细看spring-context-rediscache.xml。
  3. 功能使用。详情请看两个example项目的 controller和service层的代码。

Java
1
https://gitee.com/Fourwenwen/spring-consistent-hash.git
git@gitee.com:Fourwenwen/spring-consistent-hash.git
Fourwenwen
spring-consistent-hash
spring-consistent-hash
master

搜索帮助