Ehcache Study Summary II: EHCACHE+SPRING+MYBAITS integration

Source: Internet
Author: User

Here is the main introduction of Ehcache related configuration, spring and mybaits configuration here is just a brief introduction

1. Project Catalogue structure Display

 

2. jar package required by Ehcache

Spring-context-support-3.2.7.release.jar Spring's package is primarily used to support some other frameworks, so it is necessary to add, spring and mybaits some other jar packages to import as needed

3. Add ehcache.xml file in src directory

<?XML version= "1.0" encoding= "UTF-8"?><EhcacheXmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:nonamespaceschemalocation= "Http://ehcache.org/ehcache.xsd">     <!--Default Cache -      <Defaultcachemaxelementsinmemory= "+"Eternal= "false"Timetoidleseconds= "+"Timetoliveseconds= "+"Overflowtodisk= "false"/>                   <!--Specify the name cache cache -          <Cachename= "Studycache"maxelementsinmemory= "+"Eternal= "false"Timetoidleseconds= "+"Timetoliveseconds= "+"Overflowtodisk= "false"Memorystoreevictionpolicy= "LRU"/>            </Ehcache>

4. Join Ehcache related configuration In spring config file applicationcontext.xml

<Cache:annotation-drivenCache-manager= "CacheManager"/>      <BeanID= "Cachemanagerfactory"class= "Org.springframework.cache.ehcache.EhCacheManagerFactoryBean">          < Propertyname= "Configlocation"value= "Classpath:ehcache.xml" />      </Bean>      <BeanID= "CacheManager"class= "Org.springframework.cache.ehcache.EhCacheCacheManager">              < Propertyname= "CacheManager"ref= "Cachemanagerfactory"/>          </Bean>

5, need to cache the method before adding Ehcache annotations

@Cacheable (value= "Studycache")    public list<tradeblotter> qrytradeblotterlist ( String Appno, String opid,string Fundacct, String fundid) {        return  Apptradeblotterdao.selecttradeblotterlist (Appno, Opid, Fundacct, Fundid);    }

Ehcache Study Summary II: EHCACHE+SPRING+MYBAITS integration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.