您现在的位置是:主页 > Web前端技术 > Web前端技术
SpringBoot整合Ehcache3的实现步骤是什么开发技术
IDCBT2022-01-05【服务器技术】人已围观
简介这篇文章主要介绍“SpringBoot整合Ehcache3的实现步骤是什么”,在日常操作中,相信很多人在SpringBoot整合Ehcache3的实现步骤是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用
这篇文章主要介绍“SpringBoot整合Ehcache3的实现步骤是什么”,在日常操作中,相信很多人在SpringBoot整合Ehcache3的实现步骤是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”SpringBoot整合Ehcache3的实现步骤是什么”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
- 前言
公司部门老项目要迁移升级java版本,需要进行缓存相关操作,原框架未支持这部分,经过调研java相关缓存方案大致分为ehcache和redis两种,redis的value最大值为500mb且超过1mb会对存取有性能影响,业务系统需要支持列表查询缓存就不可避免的涉及到大量的数据存取过滤,ehcache支持内存+磁盘缓存不用担心缓存容量问题,所以框架初步版本决定集成ehcache3,设计流程结构如下图所示
缓存配置maven引用<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>org.ehcache</groupId> <artifactId>ehcache</artifactId> </dependency>个性化配置
#缓存配置 cache: ehcache: heap: 1000 offheap: 100 disk: 500 diskDir: tempfiles/cache/
@Component @ConfigurationProperties("frmae.cache.ehcache") public class EhcacheConfiguration { /** * ehcache heap大小 * jvm内存中缓存的key数量 */ private int heap; /** * ehcache offheap大小 * 堆外内存大小, 单位: MB */ private int offheap; /** * 磁盘持久化目录 */ private String diskDir; /** * ehcache disk * 持久化到磁盘的大小, 单位: MB * diskDir有效时才生效 */ private int disk; public EhcacheConfiguration(){ heap = 1000; offheap = 100; disk = 500; diskDir = "tempfiles/cache/"; } }标签:很赞哦! ()