This will introduce the use of query caching, first-level caching, level two caching in Hibernate, and the integration of spring using query caching in Hibernatetemplate. , here is Hibernate3, using hibernate4 similar, but not hibernatetemplate,DirectQuery query = getsession (). CreateQuery (HQL);Turn on level two cachingQuery.setcacheable (TRUE);Ehcache is one of Hibernate's level two cache technology, can store the query data in memory or disk, save
The author recently learned the knowledge of Web performance optimization, want to use SPRINGMVC combined with Ehcache to achieve the shared object cache, but many of the online tutorials are not very clear, coupled with my knowledge of spring is not fully familiar with, so in the implementation process encountered a variety of problems. I will now record the process of my experiment so that I can review it and give reference to the students who are s
turn on query caching) is simple with spring's AOP annotations, whereas in other query methods The main use is Ehcache, which caches the various objects returned by the method. Open Hibernate query cache and level two cache is relatively simple, here do not introduce too much, we mainly look at the use of Ehcache.1. First we use Interceptor, which defines two interceptors methodcacheinterceptor and Methodc
As a result of these two days the SPRINGMVC and MyBatis built web framework is then ready to be cached data, simply record theGet ready:Googlecode's EhcacheThis can be downloaded in the https://code.google.com/p/ehcache-spring-annotations/, downloaded after the use of the jar package Note Pack Ehcache-spring-annotations-1.2.0.jar in the downloaded Compression pack Since some of the other packages are al
Spring boot uses simplecacheconfiguration by default, that is, using Concurrentmapcachemanager to implement caching. But it's easy to switch to another cache implementation. Pom File
Introducing the appropriate jar package in the POM
configuration file
The configuration files required by Ehcache are simply placed under the classpath and Spring boot is automatically scanned.
You can also specify the location of the
roledao.getrole (ID);
}
The application.properties configuration file is as follows
#redis------start-------
spring.redis.hostname=127.0.0.1
spring.redis.port=63791
spring.redis.timeout=1000
spring.redis.maxidle=10
spring.redis.maxwaitmillis=15000
Spring.redis.testonborrow=true
Spring.redis.testwhileidle=false
The Ecache-shiro.xml configuration file is as follows (Shiro is used for this project, so Ehcache uses the Shiro cache profile)
Problems en
features of the Ehcache cache:1. Fast. 2. Simple. 3. Multiple caching Strategies 4. There are two levels of cache data: memory and disk, so there is no need to worry about capacity issues 5. The cached data is written to disk 6 during the virtual machine restart. Distributed caching can be done through RMI, pluggable APIs, and so on 7. Listening interface with cache and cache manager 8. Supports multi-cache manager instances, and multiple cache zones
Because ehcache is used in the project, the net. sf. ehcache. util. UpdateChecker doCheck will be printed every time tomcat starts.I did not pay special attention to it before. When I started Tomcat today, I found the following output information:{INFO} [07:42:10, 625] R the latest version.Later, the analysis showed that EhCache had to connect to the
1. Scene Restore
Recently, because the project involves the cache of related data, previously also wrote the Redis cache blog; But the author thinks Ehcache is compared with it, the configuration is simple, also easy to get started, so today introduces how to integrate Ehcache in Springboot Project 2. Implementation plan
① Import Ehcache Dependent
② the Spring
Reference: http://www.javaeye.com/topic/99721
There is a need to use spring to implement a simple cache solution with the following requirements: Using any of the existing open source cache frameworks requires that you can return results from a service in the cache system or Get/find in the DAO layer. If the data is updated (using the Create/update/delete method), the corresponding content in the cache is refreshed.Based on the requirements, the plan uses spring AOP +
Introduction to MC Redis Ehcache
I haven't updated my blog for a long time. I hope I can continue writing my blog later. Now I find this is a great process. I 've sorted out the usage and introduction of cache a long time ago. Now I post it as my personal notes:
Introduction to Memecached
Many Web applications save data to RDBMS. The application server reads data from the data and displays it in the browser. However, as the data volume increases an
OverviewBoth Oscache and Ehcache are process-level caches, and this article explains the features and differences between the two frameworks.OscacheOscache now no longer maintenance, but can be downloaded to use, it can cache the page, can achieve the entire page cache, can also implement the page it can cache data objects, for the page cache, we need to note: the same browser, access to the same page multiple times, will only access the business logi
To continue this article, this introduction to the service layer cache, AOP-based approach to using EhcacheFirst, modify the configuration fileModify Spring-context-ehcache.xml file, add:You can also add CacheName as "Aoptestdao" to the cache instance configuration in Ehcache-context.xmlSecond, increase the cache operation interceptorCreate a new "Cacheinterceptor.java" class under the "Org.xs.demo1" package in the "Src/main/java" code folder:Package
EhCache is a pure Java in-process caching framework, which is fast and capable, and is the default Cacheprovider in Hibernate.We use the Ehcache cache framework mainly to determine the duplicate URL, each crawl a page, the URL is stored in the cache, and each crawl a page before the cache to search under, if there is, we do not crawl this page, does not exist, we crawl down the page, crawl success, This URL
Development Letters: New Instant Messaging Capabilities (Java WebSocket communication Technology ) below--------------------------------------------------------------------------------------------------------------- ----------A Code Generator (development tool); B Ali database connection pool druid; C security Permission framework Shiro;D Ehcache Custom Level two cache; E-Interface Development (new in version 2.5 )( Activiti5 workflow will be added
This is done for both JPA and hibernate level two cachesCode directory:This is the base jar package, if less, go to maven to downloadinch Favor of SLF4J-4.11//Mvnrepository.com/artifact/net.sf.ehcache/ehcache-core --2.6.6//mvnrepository.com/artifact/org.springframework/spring-test --Ehcache.xml:"1.0"encoding="UTF-8"? >"http://www.w3.org/2001/XMLSchema-instance"xsi:nonamespaceschemalocation="http://ehcache.org/ehcache.xsd"UpdateCheck="false"> "Basecach
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.