Hibernate (14) cache and hibernate Cache

Source: Internet
Author: User

Hibernate (14) cache and hibernate Cache
1. What is cache?

The cache is between an application and a permanent mandatory data storage source. The purpose is to reduce the frequency of direct read/write of permanent mandatory data storage sources by applications, thus improving the running performance.

The cache is usually in the memory, for example:

Word and excel in Office

Sessions and SessionFactory in Hibernater

II. The Life Cycle of November in JVM
  • When the new statement creates a JAVA object, JVM allocates a memory for the current object.
  • As long as the current object is referenced by other resources, it will always exist in the memory.
  • If the current object is not referenced by other resources, the lifecycle ends.
  • If an object is referenced by another object that has not completed its lifecycle, its lifecycle will not end.
Iii. cache Scope

Iv. cache plug-ins

Ehcache. xml

<? Xml version = '1. 0' encoding = 'utf-8'?> <Ehcache> <diskStore path = "java. io. tempdir"/> <! -- MaxElementsInMemory: Total number of records that can be stored in the cache eternal: whether the current cache never expires overflowToDisk: whether to write the cached data to the local hard disk timeToIdleSeconds when the data in the current cache reaches the maximum value: the maximum idle time of the Current cache. If this time is exceeded, the cache timeToLiveSeconds will be destroyed. After the cache is created, when this time is reached, it is automatically destroyed --> <defaultCache maxElementsInMemory = "5" eternal = "false" overflowToDisk = "true" timeToIdleSeconds = "15" timeToLiveSeconds = "120"/> <>

Hibernate. cfg. xml

<? Xml version = '1. 0' encoding = 'utf-8'?> <! DOCTYPE hibernate-configuration PUBLIC "-// Hibernate/Hibernate Configuration DTD 3.0 // EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <! -- Generated by MyEclipse Hibernate Tools. --> 

Object Configuration

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><!--     Mapping file autogenerated by MyEclipse Persistence Tools-->

 

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.