oscache 与 ehcache的对比

一.ehcache主要是对数据库访问的缓存,相同的查询语句只需查询一次数据库,

从而提高了查询的速度,使用spring的AOP可以很容易实现这一功能.

http://ehcache.sourceforge.net/

ehcache.xml

<cache name="sampleCache1"

  1.         maxElementsInMemory="10000"
  2.         eternal="false"
  3.         timeToIdleSeconds="300"
  4.         timeToLiveSeconds="600"
  5.         overflowToDisk="true"
  6.         />
  7. org.springframework.cache.ehcache.EhCacheManagerFactoryBean
  8. org.springframework.cache.ehcache.EhCacheFactoryBean
  9. org.springframework.aop.support.RegexpMethodPointcutAdvisor

 

二.  oscache 主要是对页面的缓存,可以整页或者指定网页某一部分缓存,同时

指定他的过期时间,这样在此时间段里面访问的数据都是一样的

1.log4j-1.2.8.jar,oscache-2.3.2.jar,commons-logging.jar,jgroups-all.jar

2.拷贝cach\etc\下的oscache.tld,oscache.properties 到WEB-INF\classes

3.web.xml

<taglib><taglib-uri>oscache</taglib-uri><taglib-location>/WEB-INF/classes/ oscache.tld</taglib-location></taglib>

  1.    <filter>
  2.    <filter-name>CacheFilter</filter-name>
  3.    <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class>
  4.      <init-param>
  5.            <param-name>time</param-name>
  6.            <param-value>60</param-value>
  7.      </init-param>
  8.      <init-param>
  9.           <param-name>scope</param-name>
  10.           <param-value>session</param-value>
  11.       </init-param>
  12.    </filter>
  13. <filter-mapping>
  14.        <filter-name>CacheFilter</filter-name>
  15.        <url-pattern>/*.jsp</url-pattern>
  16. </filter-mapping>

http://www.opensymphony.com/oscache/download.html下载Oscache的最新版本

  1. da shang
    donate-alipay
               donate-weixin weixinpay

发表评论↓↓