您的位置:首页 > 其它

第2.3.1章 WEB系统最佳实践属性配置之ehcache.xml

2016-10-24 19:28 459 查看
ehcache.xml里面主要是配置缓存的名称和策略,另外就是缓存存放的路径。

windows、linux下面支持这种方式
<diskStore path="/usr/local/cache/monitorcache"/>
,但是mac电脑不支持。

第2.1.7章 WEB系统最佳实践Spring文件配置之spring-shiro.xml引用的就是下面配置的属性

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true" monitoring="autodetect"
dynamicConfig="true">

<diskStore path="/usr/local/cache/monitorcache"/>

<!-- 登录记录缓存 锁定10分钟 -->
<cache name="passwordRetryEhcache"
maxEntriesLocalHeap="2000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="0"
overflowToDisk="false"
statistics="true">
</cache>

<cache name="authorizationCache"
maxEntriesLocalHeap="2000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="0"
overflowToDisk="false"
statistics="true">
</cache>

<cache name="authenticationCache"
maxEntriesLocalHeap="2000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="0"
overflowToDisk="false"
statistics="true">
</cache>

<cache name="shiro-activeSessionCache"
maxEntriesLocalHeap="2000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="0"
overflowToDisk="false"
statistics="true">
</cache>

<defaultCache
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000"
diskSpoolBufferSizeMB="30"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
statistics="false"
/>

</ehcache>


注意上面
<diskStore path="/usr/local/cache/monitorcache"/>
这段缓存路径的配置,在windows和linux都可以,但是mac电脑不会自行创建,会提示如下异常。路径就得自己创建了。

nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehcacheManager' defined in file [/Users/cbb/Documents/workspace/fofweb/fofeasy/target/classes/spring/spring-cache.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Could not create cache directory "/usr/local/cache/fofeasycache".
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ehcache