Extracted from the Ehcache jar bag.~ Licensed to the Apache software Foundation (ASF) under one ~ or more contributor license agreements. See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership. The ASF licenses this file ~ under the Apache License, Version 2.0 (the ~ "License"); Except in compliance ~ with the License. Obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0
xsi:nonamespaceschemalocation= "Http://ehcache.org/ehcache.xsd" updatecheck= "false"Cache configurationName: Cache names.Maxelementsinmemory: Maximum number of caches.Eternal: The object is permanently valid, but if set, timeout will not work.Timetoidleseconds: Sets the allowable idle time (in seconds) for an object before it expires. An optional property is used only if the Eternal=false object is not permanently valid, and the default value is 0, which means that the idle time is infinite.Time
Ehcache default configuration in order to improve efficiency, so that a portion of the cache is in memory, and then reached the total amount of memory objects configured, then based on the policy persisted to the hard disk, here is a problem, if the system suddenly interrupted the memory of those caches, directly released, can not be persisted to the hard disk This data loss, for the general project is not affected, but for our crawler system, we are
EhCache supports two topologies: DistributedCaching and ReplicatedCachingDistributedCaching, which are similar to distributed caching in general, this type of cache is divided into client-server. The application requests the cached data from the client to the server. on the server side, the data is in the form of EhCache that supports two topologies, one is Dis.
TrIbut
EdCaching, the other is Repli
CatEd Ca
I.Ehcache is mainly used to cache database access. Only one database query is required for the same query statement.,
This improves the query speed. Spring AOP can easily implement this function.
Http://ehcache.sourceforge.net/
Ehcache. xml
XML
Code
Maxelementsinmemory="10000"
Eternal="False"
Timetoidleseconds="300"
Timetoliveseconds="600"
Overflowtodisk="True"
/>
Org. springframework. cache.
1. First set ehcache and create the configuration file ehcache. xml. The default location is class-path, which can be placed in your src directory:
xml version="1.0" encoding="UTF-8"?> maxElementsInMemory="10000" eternal="false" overflowToDisk="true" timeToIdleSeconds="300" timeToLiveSeconds="180" diskPersistent="false" diskExpiryThreadIntervalSeconds= "120"/>
About the Key ClassesEhcache consists of a CacheManager, which manages logical data sets represented as Caches. A Cache object contains Elements, which is essentially name-value pairs. You can use the cache objects to hold any kind of data so you want to keep in memory, not just data, the want to Cache.Caches is physically implemented, either in-memory or on disk. The logical representations of these components is actualized mostly through the following classes:
CacheManager
Cache
1. First go to the official Download Spring jar package, I use sring 4.1.6 has integrated the Ehcache.2. Write the spring configuration file, and note that you need to add the cache constraint file.Xmlns:cache= "Http://www.springframework.org/schema/cache"Http://www.springframework.org/schema/cacheHttp://www.springframework.org/schema/cache/spring-cache.xsd3. Configure the Ehcache cache Manager in the Sprin
[Java] EhCache event listener for preventing caching of null values in data store (ehcache listener, clear when strong value is null) [java] [java] ehcache configuration
causing GC pauses).The memory store has the following characteristics:
Accepts all data, whether serializable or not
Fastest storage option
Thread safe for use by multiple concurrent threads
The memory store is the top tier and are automatically used by Ehcache to store the data hotset because it is the faste St store. It requires no special configuration to enable, and its overall size was taken from the Java heap size. Since i
Ehcache with SpringCache main Annotations Use:@Cacheable, @CacheEvict, @CachePutThe following Web sites can be used for syntax and configuration purposes:1 . Very detailed use of spring MVC and Cache blog (note-driven Spring cache introduction)http://www.ibm.com/developerworks/cn/opensource/os-cn-spring-cache/2. Official documentsHttp://docs.spring.io/spring/docs/3.1.0.M1/spring-framework-reference/html/cache.html3,
; }}Cachinguserdetailsservice the default Usercache property value is new NullUserCache() that the object does not implement caching. Because I'm going to use Ehcache to cache userdetails, I need to use Spring's Ehcachebasedusercache class, which is the implementation class for the Usercache interface, primarily the caching operation.The specific implementation of cache userdetails to Ehcache is as follows:
A Code Generator (development tool); B Ali database connection pool Druid; C security permission framework Shiro; D Ehcache Custom Level two cache System formainstreamof theSpringmvc+mybaits 3.2versions, with maven and non-maven versions, giving the same UIHibernateversion (support sqlsever MySQL Oracle) JDK 1.6 1.7 1.8 Tomcat 6 7 8 (responsive phone PC tablet bottom phone )1. There are 5 sets of Oracle, MSYQL, spring3.0, spring4.0 all provide no hi
A Code Generator ( development tool ); B Ali database connection pool Druid;C Security Permission framework Shiro ; D Ehcache Custom Level two cache ( subsequent join of Activiti5 workflow )System for mainstream of the Springmvc+mybaits 3.2 version that provides maven of the Pom.xml documents, free of charge Hibernate version set (Collapse database)1. There are 4 sets of Oracle, MSYQL, spring3.0, spring4.0 all provided without hitting the jar with
A Code Generator ( development tool ); B Ali database connection pool Druid;C Security Permission framework Shiro ; D Ehcache Custom Level two cache ( subsequent join of Activiti5 workflow )System for mainstream of the Springmvc+mybaits 3.2 version that provides maven of the Pom.xml documents, free of charge Hibernate version set (Collapse database)1. There are 4 sets of Oracle, MSYQL, spring3.0, spring4.0 all provided without hitting the jar with
First: The introduction between the two
Redis: A standalone running program that needs to be installed separately and manipulated using Jedis in Java. Because it is independent, so if you write a unit test program, put some data in the Redis, and then write a program to get the data, then you can get the data. ,
Ehcache: Unlike Redis, which is tied to the Java program, the Java program is alive, and it's alive. For example, write a separate program to
Tags: number of post infinite package row data configuration resource value aboutRecently doing a small project requires caching a batch of data and requiring persistence to disk. Using Ehcache is very simple and intuitive, generally only need to configure Ehcache.xml files, and then directly use @cacheable, @Cacheput, @CacheEvict can.The meaning of the three annotations is also very simple, here is not to say.The Ehchche.xml configuration is simple a
Description of parameters used by EhcacheParameter description in 1.ehcache.xmlEhcache.xml file:Parameter description:: When the number of objects in the memory cache exceeds maxelementsinmemory, the cache object is written to the disk cache (requires the object to implement the serialization interface).: Used to configure the physical path used by the disk cache, the Ehcache disk cache uses a file suffix of *.data and *.index.Name: The cache name, th
1. EHCache features, is a pure Java, the process (can also be understood as a plug-in) cache implementation, the installation of EHCache, the need to Ehcache-x.x.jar and related class library to classpath. If Hibernate is already installed on the project, you do not need to do anything. Direct access to EhcacheCache storage mode: Memory or disk2. Use
Ehcache is the current more popular cache framework, the use of caching can greatly alleviate the pressure on the server and database, improve access efficiency, improve the server's concurrency capabilities. Next we'll see how to use the cache.
SPRINGMVC the required jar packs for integrated Ehcache:
including Ehcache-core-2.4.3.jar,
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.