Ehcache one or two things-simple configuration application of Ehcashe in SSM

Source: Internet
Author: User

Ehcache is an open source Java distributed cache. Can be used with MyBatis first, create a new ehcache.xml content in the resource folder as follows:
1 <?XML version= "1.0" encoding= "UTF-8"?>  2 <EhcacheXmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"  3 xsi:nonamespaceschemalocation=".. /bin/ehcache.xsd ">  4     <DefaultcacheOverflowtodisk= "true"Eternal= "false"maxelementsinmemory= "1"/>  5     <!--the path address needs to be modified in the production environment -6     <!--Dev -7     <DiskstorePath= "D:/cache" />8     <!--Product Linux -9 <!--<diskstore path= "XXX"/> -Ten </Ehcache>  

Must be serialized in its own model, the serialization ID must be generated automatically (also in Redis)

Add the following ehcache to the Mapper.xml:

1     <!--  -2<!--     -3     <!-- -4 < type = "       Org.mybatis.caches.ehcache.EhcacheCache "/>

The UseCache in the select expression is true by default, the cache is used, and if not, it is set to false.

After testing, the first query will have the output of SQL, the second start of the same query is not

Cache files on the hard disk

Ehcache one or two things-simple configuration application of Ehcashe in SSM

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.