java技术研究

统计

留言簿(3)

阅读排行榜

评论排行榜

缓存备忘ehcache和oschache

1、定义ehcache
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
  <property name="configLocation" value="classpath:conf/spring/spring_ehcache.xml" />
 </bean>
2、在spring中联合oscache
 <bean id="cacheFilterBean" class="com.ebizer.framework.core.filter.CacheFilter">
  <property name="cacheUris">
     <list>
      <!--
       <value>/index.html</value>
       <value>/trend.html</value>
       <value>/trend/newest.html</value>
        -->
     </list>
    </property>
 </bean>
3、定义ehcache的方法
<!-- Remove the following 3 beans to disable method level data cache -->
 <bean id="methodCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
  <property name="cacheManager" ref="cacheManager" />
  <property name="cacheName" value="METHOD_CACHE" />
 </bean>  
 <bean id="methodCacheLong" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
  <property name="cacheManager" ref="cacheManager" />
  <property name="cacheName" value="METHOD_CACHE_LONG" />
 </bean>
 <bean id="methodCacheViewHot" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
  <property name="cacheManager" ref="cacheManager" />
  <property name="cacheName" value="METHOD_CACHE_VIEW_HOT_MATCH_ITEM" />
 </bean>  
 <bean id="methodCacheIndex" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
  <property name="cacheManager" ref="cacheManager" />
  <property name="cacheName" value="METHOD_CACHE_INDEX" />
 </bean>
 
 <bean id="methodCacheInterceptorIndex" class="com.ebizer.framework.core.interceptor.MethodCacheInterceptor">
  <property name="cache" ref="methodCacheIndex" />
 </bean>
 <bean id="methodCacheInterceptor" class="com.ebizer.framework.core.interceptor.MethodCacheInterceptor">
  <property name="cache" ref="methodCache" />
 </bean>
 <bean id="methodCacheInterceptorLong" class="com.ebizer.framework.core.interceptor.MethodCacheInterceptor">
  <property name="cache" ref="methodCacheLong" />
 </bean>   
 <bean id="methodCacheInterceptorViewHot" class="com.ebizer.framework.core.interceptor.MethodCacheInterceptor">
  <property name="cache" ref="methodCacheViewHot" />
 </bean> 
 
 <bean id="methodCacheAdvisorTemplate" abstract="true" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
  <property name="advice" ref="methodCacheInterceptor" />
 </bean> 
 <bean id="methodCacheAdvisorTemplateLong" abstract="true" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
  <property name="advice" ref="methodCacheInterceptorLong" />
 </bean> 
 <bean id="methodCacheAdvisorTemplateViewHot" abstract="true" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
  <property name="advice" ref="methodCacheInterceptorViewHot" />
 </bean> 

posted on 2012-08-22 14:21 小秦 阅读(664) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: