SpringBoot整合J2Cache

简介

J2Cache 是 OSChina 目前正在使用的两级缓存框架(要求至少 Java 8)。第一级缓存使用内存(同时支持 Ehcache 2.x、Ehcache 3.x 和 Caffeine),第二级缓存使用 Redis(推荐)/Memcached 。 由于大量的缓存读取会导致 L2 的网络成为整个系统的瓶颈,因此 L1 的目标是降低对 L2 的读取次数。 该缓存框架主要用于集群环境中。单机也可使用,用于避免应用重启导致的缓存冷启动后对后端业务的冲击。

导入jar包

<dependency>
            <groupId>net.oschina.j2cache</groupId>
            <artifactId>j2cache-core</artifactId>
            <version>2.7.8-release</version>
        </dependency>
        <dependency>
            <groupId>io.lettuce</groupId>
            <artifactId>lettuce-core</artifactId>
        </dependency>

引入配置文件j2cache.properties

#J2Cache configuration

#########################################
#Cache Broadcast Method
#values:
#jgroups -> use jgroups's multicast
#redis -> use redis publish/subscribe mechanism (using jedis)
#lettuce -> use redis publish/subscribe mechanism (using lettuce, Recommend)
#rabbitmq -> use RabbitMQ publisher/consumer mechanism
#rocketmq -> use RocketMQ publisher/consumer mechanism
#none -> don't notify the other nodes in cluster
#xx.xxxx.xxxx.Xxxxx your own cache broadcast policy classname that implement net.oschina.j2cache.cluster.ClusterPolicy
#########################################

j2cache.broadcast = lettuce

#jgroups properties
#jgroups.channel.name = j2cache
#jgroups.configXml = /network.xml

#RabbitMQ properties
#rabbitmq.exchange = j2cache
#rabbitmq.host = 7.11.16
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值