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"