Level 1 cache and level 2 Cache and query Cache

Source: Internet
Author: User

A) Open up A space in the memory and place the things used on the hard disk in the memory, for future use, take <defaultCache maxElementsInMemory = "10000" // maximum number of objects to be put eternal = "false" // permanently stored timeToIdleSeconds = "120" // s to eliminate timeToLiveSeconds =" 1200 "// survival time overflowToDisk =" true "// when overflow occurs on the hard disk/> Level 2 cache, sessionFactory-level cache, which can exist across sessions. I is frequently accessed. Ii changes are not often changed. The number of Iii Changes is limited. For example: User, organizational unit Activation Process:. in hibernate. cfg. <property name = "hibernate. cache. provider_class "> net. sf. ehcache. hibernate. ehCacheProvider </property> B. introduce ehcache In the src directory. xml configuration file c. in hbm. add <cache> element <cache usage = "read-write" region = "sampleCache1"/> to xml: @ Cache (usage = CacheConcurrencyStrategy. READ_ONLY) Load uses the second-level cache by default, and iterate uses the second-level cache by default. Repeat the cache List uses the second-level cache and data, but it is not used for query, because the structure of each query is different, you cannot query www.2cto.com repeatedly. cache: Used to cache HQL statements and results with the same parameter values. it is used based on second-level cache. <property name = "cache. use_query_cache "> true </property>. in hibernate. cfg. enable query cache in xml. in the execution of query. call query before list. setCacheable (true); c. cache algorithm: LRU, LFU, and FIFOLeast recently Used recently, Least frequently used is not Used. Low hit rate: First in first out First out memoryStoreEvictionPplicy = "LRU"

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.