oscache 與 ehcache的對比


一.ehcache主要是對數據庫訪問的緩存,相同的查詢語句只需查詢一次數據庫,

  從而提高了查詢的速度,使用spring的AOP可以很容易實現這一功能.

  http://ehcache.sourceforge.net/

  ehcache.xml

     <cache name="sampleCache1"

Xml代碼 
  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> 

Xml代碼 
  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.   
  13.    </filter>  
  14. <filter-mapping>  
  15.        <filter-name>CacheFilter</filter-name>    
  16.        <url-pattern>/*.jsp</url-pattern>  
  17. </filter-mapping>      

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

 java進階網 http://www.javady.com/index.php/category/big_data


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM