缓存 ehcache
2024-09-06 18:25:38
只是用于自己记录,防止日后忘记,回看所用
第一步:配置ehcahe 缓存
<?xml version="1.0" encoding="UTF-8"?> <ehcache>
<!--
磁盘存储:将缓存中暂时不使用的对象,转移到硬盘,类似于Windows系统的虚拟内存
path:指定在硬盘上存储对象的路径
-->
<diskStore path="C:\ehcache" /> <!--
defaultCache:默认的缓存配置信息,如果不加特殊说明,则所有对象按照此配置项处理
maxElementsInMemory:设置了缓存的上限,最多存储多少个记录对象
eternal:代表对象是否永不过期
overflowToDisk:当内存中Element数量达到maxElementsInMemory时,Ehcache将会Element写到磁盘中
-->
<defaultCache
maxElementsInMemory=""
eternal="true"
overflowToDisk="true"/> <!--
下面这是自己配置了一个缓存
-->
<cache
name="a"
maxElementsInMemory=""
eternal="true"
overflowToDisk="true"/>
</ehcache>
第二步: 整合spring 和 ehcahe(即将ehcache 以bean的方式注入到 IOC 容器中)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-3.1.xsd"> <bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml" />
<property name="shared" value="true"/>
</bean> <!-- 开启spring缓存 -->
<!-- 注解开发启动 -->
<cache:annotation-driven cache-manager="cacheManager" /> <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehCacheManager"></property>
</bean>
</beans>
第三步: 就可以在方法或者其他位置上使用注解驱动,来使用缓存技术啦
(后期有待完善,望体谅)
最新文章
- 不完全解决Android微信HTML5 播放视频的问题(不显示控制条,可交互)
- Comet服务器推送与SignalR
- asp.net 发送邮件
- Linux 挂载新硬盘
- DEPRECATED: Use of this script to execute hdfs command is deprecated.
- 再回首,Java温故知新(一):Java概述
- coalesce和nvl函数
- ASP.NET MVC 使用Uploadify实现多文件异步无刷新上传
- ExtJs6级联combo的实现
- Activity的状态保存
- Linux coredump解决流程
- Win10安装docker的一些注意事项
- 多项式细节梳理&;模板(多项式)
- JS元素意外点击元素消失
- 【Java】代理模式、反射机制-动态代理
- Socket网络编程--聊天程序(8)
- [转载]grep查看上下文及简单正则表达式
- python的Web框架,Django模板变量,过滤器和静态文件引入
- Java POI单元格使用心得
- MSDN离线版 发现不少人都在找这个
热门文章
- Google老师亲授 TensorFlow2.0实战: 入门到进阶
- 机器学习之——集成算法,随机森林,Bootsing,Adaboost,Staking,GBDT,XGboost
- Centos虚拟机安装指南
- 分布式唯一ID:雪花ID Snowflake .Net版
- SQL练习题(一)
- rabbitmq系列(二)几种常见模式的应用场景及实现
- Prometheus+Alertmanager+Grafana监控组件容器部署
- Python工具类(二)—— 操作时间相关
- <;密码学系列>;—信息安全威胁
- options请求(复杂请求)