纯Java的进程内缓存框架-EhCache
来源:互联网 发布:淘宝电商培训心得体会 编辑:程序博客网 时间:2024/05/16 12:16
Java缓存框架 EhCache EhCache 是一个纯Java的进程内缓存框架,具有快速、精干等特点,是Hibernate中默认的CacheProvider。
JAVA实例:
package test.ehcache;import net.sf.ehcache.Cache;import net.sf.ehcache.CacheManager;import net.sf.ehcache.Element;public class TestCache {public static void main(String[] args) {/** * Create a singleton CacheManager using defaults, then list caches. */CacheManager.create();String[] cacheNames = CacheManager.getInstance().getCacheNames();System.out.println(cacheNames.length);/** * Create one CacheManager with a configuration, and list the caches in each. */CacheManager manager2 = CacheManager.newInstance("ehcache1.xml");String[] cacheNames2 = manager2.getCacheNames();System.out.println(cacheNames2.length);/** * Create a Cache and add it to the CacheManager, then use it. * Note that Caches are not usable until they have been added to a CacheManager. */CacheManager singletonManager = CacheManager.create();Cache memoryOnlyCache = new Cache("testCache", 5000, false, false, 5, 2);singletonManager.addCache(memoryOnlyCache);Cache cache = singletonManager.getCache("testCache");Element element = new Element("key1","value1");cache.put(element);Element value = cache.get("key1");System.out.println(value.getObjectValue());//value1System.out.println(value.toString());//[ key = key1, value=value1, version=1, hitCount=1, CreationTime = 1359130974484, LastAccessTime = 1359130974500 ]}}
配置文件ehcache1.xml:
<?xml version="1.0" encoding="UTF-8"?><ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"monitoring="autodetect" dynamicConfig="true"><diskStore path="user.dir" /><defaultCache name="default-cache"maxElementsInMemory="10000" maxElementsOnDisk="0"eternal="false" overflowToDisk="true" timeToIdleSeconds="1200"timeToLiveSeconds="1200"></defaultCache><cache name="my-cache" maxElementsInMemory="10000"maxElementsOnDisk="0" eternal="false" overflowToDisk="true"diskSpoolBufferSizeMB="20" timeToIdleSeconds="300" timeToLiveSeconds="600"memoryStoreEvictionPolicy="FIFO"></cache></ehcache><!--Default Cache configuration. These will applied to caches programmatically created through the CacheManager. The following attributes are required for defaultCache: maxInMemory - Sets the maximum number of objects that will be created in memory eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the element is never expired. timeToIdleSeconds - Sets the time to idle for an element before it expires. Is only used if the element is not eternal. Idle time is now - last accessed time timeToLiveSeconds - Sets the time to live for an element before it expires. Is only used if the element is not eternal. TTL is now - creation time overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache has reached the maxInMemory limit. -->
- 纯Java的进程内缓存框架-EhCache
- 纯Java的进程内缓存框架-EhCache
- EhCache 是一个纯Java的进程内缓存框架
- Java的进程内缓存框架:EhCache
- 进程内缓存框架EhCache
- 进程内缓存框架 EhCache
- 进程内缓存框架 EhCache
- Ehcache纯Java缓存框架
- EhCache 是一个纯Java的进程内缓存框架,具有快速、精干等特点,是hibernate中默认的CacheProvider Ehcache是一种广泛使用的开源Java分布式缓存。主要面向通
- Ehcache是现在最流行的纯Java开源缓存框架
- Ehcache是现在最流行的纯Java开源缓存框架
- Ehcache是现在最流行的纯Java开源缓存框架
- Ehcache是现在最流行的纯Java开源缓存框架
- Ehcache是现在最流行的纯Java开源缓存框架
- Ehcache是现在最流行的纯Java开源缓存框架
- Ehcache是现在最流行的纯Java开源缓存框架
- Ehcache是现在最流行的纯Java开源缓存框架
- Ehcache是现在最流行的纯Java开源缓存框架
- GitHub上优秀Android开源项目(二)
- MapReduce的工作机制
- HDU 2018
- CentOS 5.3 PPTP VPN 安装
- 网络直播:挨踢项目求生法则(2)——战略篇
- 纯Java的进程内缓存框架-EhCache
- sublime && c++ 配置问题
- pthread_cleanup_push和pthread_cleanup_pop
- ARM-LINUX-2.6.36-LDD3-scull
- NSString什么时候用copy,什么时候用strong
- 史上最难数独求解,用时约5秒,回溯法,deepcopy是关键
- 历史的今天
- 我的学习生涯(Delphi篇) - 15
- linux 下查找文件或者内容常有命令