ehcache
ehcache 缓存
是专门缓存插件, 可以缓存java 对象, 提供系统性能
1\ MAVEN 导包
2\ ehcache.xml
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../config/ehcache.xsd"> <diskStore path="java.io.tmpdir" /> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" maxElementsOnDisk="10000000" diskPersistent="false" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" /> </ehcache>
3\ spring.xml
<!-- 注册安全管理器对象 --> <bean name="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <!-- 注入realm --> <property name="realm" ref="bosRealm"></property> <!-- 注入缓存 --> <property name="cacheManager" ref="cacheManager"></property> </bean> <!-- 注册realm --> <bean name="bosRealm" class="com.stevezong.bos.realm.BosRealm"></bean> <!-- 注册ehcache 缓存管理器 --> <bean name="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager"> <!-- 注入ehcache的配置文件 --> <property name="cacheManagerConfigFile" value="classpath:conf/ehcache.xml"></property> </bean>
浙公网安备 33010602011771号