Ehcache配置文件

百科:http://baike.baidu.com/link?url=atVCMfHUCkH7fdWmP41OL_kpyAmACcij4ffVTGg_mXtgoequLcIp1BwIiIJz7NyIPJhlWhvW7zs2L1HuhhDSOq


<ehcache>


<!--磁盘存储配置:用来指定缓存在磁盘上的存储位置。
可以使用JavaVM环境变量(user.home, user.dir, java.io.tmpdir)-->
<diskStore path = "c:/cache/" />

<!--指定CacheManagerEventListenerFactory,这个对象在缓存添加的时候会得到相应的通知。
CacheManagerEventListenerFactory的属性:
*class :CacheManagerEventListenerFactory的一个实现类。
*properties :CacheManagerEventListenerFactory的属性值,以逗号(,)分割多个属性。
如果没有实现类被指定,则系统不创建CacheManager的监听器,没有默认值-->
<cacheManagerEventListenerFactory class="" properties="" />

<!--在进行分布式缓存的应用时需要指定CacheManagerPeerProviderFactory,用来生成CacheManagerPeerProvider的实例,以便和集群中的其他CacheManager通信。
CacheManagerPeerProvider的属性:
*class :CacheManagerPeerProviderFactory的一个实现类。
*properties :CacheManagerPeerProviderFactory的属性值,以逗号(,)分割多个属性。

Ehcache内建了2种基于RMI分布系统的通信策略:
*automatic :使用多播组。在一个节点加入或者推出集群的时候自动感应。
*manual :硬编码方式
-->
<cacheManagerPeerListenerFactory class="" properties="" />

<!--默认缓存配置,以下属性是必须的:
name :cache的标识符,在一个CacheManager中必须唯一。
maxElementsInMemory : 在内存中缓存的element的最大数目。
maxElementsOnDisk : 在磁盘上缓存的element的最大数目。
eternal : 设定缓存的elements是否有有效期。如果为true,timeouts属性被忽略。
overflowToDisk : 设定当内存缓存溢出的时候是否将过期的element缓存到磁盘上。

以下属性是可选的:
timeToIdleSeconds : 缓存element在过期前的空闲时间。
timeToLiveSeconds : 缓存element的有效生命期。
diskPersistent : 在VM重启的时候是否持久化磁盘缓存,默认是false。
diskExpiryThreadIntervalSeconds : 磁盘缓存的清理线程运行间隔,默认是120秒.
memoryStoreEvictionPolicy : 当内存缓存达到最大,有新的element加入的时候,
移除缓存中element的策略。默认是LRU,可选的有LFU和FIFO

缓存子元素:
cacheEventListenerFactory:注册相应的的缓存监听类,用于处理缓存事件,如put,remove,update,和expire
bootstrapCacheLoaderFactory:指定相应的BootstrapCacheLoader,用于在初始化缓存,以及自动设置。
-->
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="1000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
<!--cache配置同defaultCache -->
<cache name="test"
maxElementsInMemory="100"
eternal="false"
timeToIdleSeconds="100"
timeToLiveSeconds="100"
overflowToDisk="false"
/>

</ehcache>


来源于:http://blog.csdn.net/java000/article/details/2697892

另外再给大家推荐一篇文章,详细的讲解的ehcache的特性

http://raychase.iteye.com/blog/1545906


发布了108 篇原创文章 · 获赞 59 · 访问量 106万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章