前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Git 项目推荐 | 基于 J2Cache 的多级缓存框架

Git 项目推荐 | 基于 J2Cache 的多级缓存框架

作者头像
码云Gitee
发布2018-03-29 10:59:57
7070
发布2018-03-29 10:59:57
举报
文章被收录于专栏:开源项目开源项目

基于j2cache的理念,重新设计开发的一套分布式缓存。支持2级并不限于2级的多级缓存系统。

github地址:atoms

配置文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?><atoms>
    <broadcast type="redis" >
        <broadcastConfig host="192.168.1.53" port="6379"/>
    </broadcast>
    <serializer type="fst"/>
    <cache level="1" type="ehcache" delete_atom="true" ><!-- expiredOperator="update" waitTime="100" --><!-- expiredOperator: update,delete  当为update时waitTime有效-->
        <cacheConfig configFile="ehcache.xml"/>
    </cache>
    <cache level="2" type="redis">
        <cacheConfig host="192.168.1.53" port="6379" timeout="2000" database="13" namespace="atoms" maxTotal="-1" maxIdle="2000"
         maxWaitMillis="100" minEvictableIdleTimeMillis="864000000" minIdle="1000" numTestsPerEvictionRun="10" lifo="false"
         softMinEvictableIdleTimeMillis="10" testOnBorrow="true" testOnReturn="false" testWhileIdle="false" timeBetweenEvictionRunsMillis="300000"
         blockWhenExhausted="true" password=""/>
    </cache>
    <cache level="3" type="redis">
        <cacheConfig host="192.168.1.22" port="6379" timeout="2000" database="13" namespace="atoms" maxTotal="-1" maxIdle="2000"
         maxWaitMillis="100" minEvictableIdleTimeMillis="864000000" minIdle="1000" numTestsPerEvictionRun="10" lifo="false"
         softMinEvictableIdleTimeMillis="10" testOnBorrow="true" testOnReturn="false" testWhileIdle="false" timeBetweenEvictionRunsMillis="300000"
         blockWhenExhausted="true" password=""/>
    </cache></atoms>

使用代码:

代码语言:javascript
复制
CacheChannel cc=CacheChannel.getInstance();cc.set("jobell", "hello", "nihaoya");cc.evict("jobell", "hello");while(true){
    Object value=cc.get("jobell", "hello");
    if(value==null){
        System.out.println("==============="+value);
    }else{
        System.out.println("==============="+value);
    }}
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2016-06-30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Gitee 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档