Spring Data JPA L2 Cache Settings

测试通过

<!--Ehcache-core 包 -->
<dependency>
      <groupId>net.sf.ehcache</groupId>
      <artifactId>ehcache-core</artifactId>
      <version>2.6.9</version>
</dependency>

<!--添加Hibernate-Ehcache包 -->
<dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-ehcache</artifactId>
      <version>${hibernate.version}</version>
</dependency>

添加资源文件
ehcache.xml
<?xml version="1.0" encoding="UTF-8"?>
<ehcache name="syscache">
    <diskStore path="java.io.tmpdir"/>
      <defaultCache
           maxEntriesLocalHeap="10000"
           eternal="false"
           overflowToDisk="true"
           timeToIdleSeconds="20"
           timeToLiveSeconds="60">
      </defaultCache>
</ehcache>

http://www.litianhua.net/blog/jpa-second-level-cache.html

Inside
FavoriteAdd to favorites
Introduction: In the first two months, I wrote two articles "Framework integration and coding testing of Spring and JPA." and "Support and use of JPA Criteria query.", which mainly include the integration of frameworks and related code. demo. Today's article is based on the above article to expand, mainly for the primary use of the second level cache to facilitate performance optimization, but this article does not involve performance optimization, just the primary configuration and use. In addition, you can also take a look at the article "In-depth understanding of Hibernate Cache." I believe that after reading this article, you will be able to read this article with ease and be more impressed.

If you haven't read the two articles "Framework Integration and Coding Testing of Spring and JPA." and "Support and Use of JPA Criteria Query.", it is recommended to read it first. The following configuration and code demonstrations are based on the demonstration codes in these two articles.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326317579&siteId=291194637