ehcahce 的页面缓存 配置简单
来源:互联网 发布:mac系统绘画软件 编辑:程序博客网 时间:2024/05/18 17:00
地址:http://ljh0721.iteye.com/blog/1797987
ehcache页面缓存
- 博客分类:
- 缓存
ehcahce 的页面缓存 配置简单
需要导入ehcache-web-2.0.4.jar 和ehcache-core-2.6.3.jar (页面缓存web包是必须要有的)可从http://sourceforge.net/projects/ehcache/files/下载最新的jar包
1、在web.xml中配置(在struts2的过滤器之前)
- <filter>
- <filter-name>CachePageCachingFilter</filter-name>
- <filter-class>net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter
- </filter-class>
- <init-param>
- <param-name>suppressStackTraces</param-name>
- <param-value>false</param-value>
- </init-param>
- <init-param>
- <param-name>cacheName</param-name>
- <param-value>CachePageCachingFilter</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>CachePageCachingFilter</filter-name>
- <url-pattern>*.action</url-pattern>
- </filter-mapping>
2、在ehcache.xml中配置
- <cache name="CachePageCachingFilter"
- maxElementsInMemory="10"<!- 缓存最大数目 ->
- eternal="false" <!- 缓存是否持久 ->
- overflowToDisk="true" <!- 当系统当机时,是否保存到磁盘 ->
- timeToIdleSeconds="120" <!- 当缓存闲置 n 秒后销毁 ->
- timeToLiveSeconds="120" <!- 当缓存存活 n 秒后销毁->
- memoryStoreEvictionPolicy = "LFU"> <!- 缓存清除策略 ->
- </cache>
了解 ehcache的几个概念,
timeToIdleSeconds ,多长时间不访问该缓存,那么 ehcache 就会清除该缓存。
timeToLiveSeconds ,缓存的存活时间,从开始创建的时间算起。
Ehcache的三种清空策略:
1. FIFO,first in first out ,这个是大家最熟的,先进先出。
2. LFU, Less Frequently Used ,就是上面例子中使用的策略,直白一点就是讲一直以来最少被使用的。如上面所讲,缓存的元素有一个 hit 属性,hit 值最小的将会被清出缓存。
3. LRU,Least Recently Used ,最近最少使用的,缓存的元素有一个时间戳,当缓存容量满了,而又需要腾出地方来缓存新的元素的时候,那么现有缓存元素中时间戳离当前时间最远的元素将被清出缓存。
- ehcahce 的页面缓存 配置简单
- 关于Spring中ehcahce实现注解缓存的配置
- Java缓存之 Ehcahce 解读
- Ehcahce 搜索类型简单扩展
- spring+mybatis+ehcahce实现注解缓存
- 一个简单的页面缓存类
- 页面缓存 ehcache(简单的)
- SHOP++页面缓存的配置方法
- Yii 的缓存(页面缓存配置实例)
- ehcahce的diskSpoolBufferSizeMB参数解析,不能过大
- lighttpd做缓存的简单配置
- 基于servlet的简单的页面缓存框架
- nginx 缓存简单配置
- ehcache 缓存包含页面配置
- 页面缓存的困扰
- windows页面的缓存
- 页面缓存的设置
- 页面缓存的实现
- 【D3D11游戏编程】学习笔记二十一:Cube Mapping及其应用之一:天空盒的实现
- Secret of the JavaScript Ninja 学习笔记 - 1
- huffman编码及解码实现
- leetcode 71: Substring with Concatenation of All Words
- 微软认证考试70-461 Work with Data 数据处理 --27%比重--(5.5)
- ehcahce 的页面缓存 配置简单
- LeetCode3:Longest Substring Without Repeating Characters
- java 字符串 转数组 Java – How to convert String into Array
- C#中ref和out的使用小结
- ZOJ 2099 Frame PolygonalLine
- 谷歌如何通过安卓赚钱
- LeetCode4: Add Two Numbers
- main函数前的秘密
- 宝石合成升级问题