<Ehcache> <!--Specify a directory: When EHCache writes data to the hard disk, it writes the data to this directory. - <DiskstorePath= "D:\\tempdirectory"/> <!--set the default data expiration policy for the cache - <Defaultcachemaxelementsinmemory= "10000"Eternal= "false"Timetoidleseconds= "+"Timetoliveseconds= "+"Overflowtodisk= "true" /> <!--sets the data expiration policy for the specific named cache. Each named cache represents a cache region cache region: a cache block with a name that can set a different cache policy for each cache block. If no cache area is set, all cached objects will use the default cache policy. That is,:<defaultcache.../> Hibernate holds different classes/collections in different cache areas. For a class, the name of the zone is the class name. For example: Com.atguigu.domain.Customer for a collection, the name of the zone is the class name plus the property name. such as Com.atguigu.domain.Customer.orders - <!--Name: Sets the name of the cache, which is the fully qualified name of the class or the name of the collection of classes Maxelementsinmemory: Sets the maximum number of objects that can be held in the memory-based cache eternal: sets whether the object Is permanent, true means never expires, ignoring the timetoidleseconds and timetoliveseconds attributes; The default value is False timetoidleseconds: Sets the maximum amount of time the object is idle, in seconds, when the object expires. When an object expires, Ehcache clears it from the cache. If this value is 0, the object can be idle indefinitely. Timetoliveseconds: Sets the object to live for the longest time, over this time, the object expires. If this value is 0, the object can exist indefinitely in the cache.
The property value must be greater than or equal to the Timetoidleseconds property value Overflowtodisk: If the number of objects in the memory-based cache reaches the upper limit, whether to write the overflow object to the hard disk-based cache - <Cachename= "Com.atguigu.hibernate.entities.Employee"maxelementsinmemory= "1"Eternal= "false"Timetoidleseconds= "+"Timetoliveseconds= "All"Overflowtodisk= "true" /> <Cachename= "Com.atguigu.hibernate.entities.Department.emps"maxelementsinmemory= "+"Eternal= "true"Timetoidleseconds= "0"Timetoliveseconds= "0"Overflowtodisk= "false" /></Ehcache>
Manage Hibernate's Level two cache