1.创建CacheManager (net.sf.ehcache.CacheManager)
(1)使用默认配置文件创建
CacheManager manager = CacheManager.create();
(2)使用指定配置文件创建
CacheManager manager = CacheManager.create("src/config/ehcache.xml");
(3)从classpath找寻配置文件并创建
URL url = getClass().getResource("/anothername.xml");
CacheManager manager = CacheManager.create(url);
(4)通过输入流创建
InputStream fis = new FileInputStream(new File("src/config/ehcache.xml").getAbsolutePath());
try { manager = CacheManager.create(fis); } finally { fis.close(); }
2.创建Caches (net.sf.ehcache.Cache)
(1)取得配置文件中预先 定义的sampleCache1设置,生成一个Cache
Cache cache = manager.getCache("sampleCache1");
(2)设置一个名为test 的新cache,test属性为默认
CacheManager manager = CacheManager.create();
manager.addCache("test");
(3)设置一个名为test 的新cache,并定义其属性
CacheManager manager = CacheManager.create();
Cache cache = new Cache("test", 1, true, false, 5, 2);
manager.addCache(cache);
(4)删除cache
CacheManager singletonManager = CacheManager.create();
singletonManager.removeCache("sampleCache1");
3.使用Caches
(1)往cache中加入元素
Element element = new Element("key1", "value1");
cache.put(new Element(element);
(2)从cache中取得元素
Element element = cache.get("key1");
(3)从cache中删除元素
Cache cache = manager.getCache("sampleCache1");
Element element = new Element("key1", "value1");
cache.remove("key1");
4.卸载CacheManager ,关闭Cache
manager.shutdown();
分享到:
相关推荐
NULL 博文链接:https://luyao123127.iteye.com/blog/1312099
springboot2.0使用ehcache缓存,这个压缩包时一个简单的demo。
ehcache3-samples, 关于使用 Ehcache 3,一些示例/教程 Ehcache示例这里知识库包含有关 Ehcache 3用法的示例和教程。示例'basic'演示 Ehcache 3的基本配置和用法'集群'- 演示如何在Terracotta服务器上使用分布式缓存...
在Spring+Hibernate集成环境中使用EhCache缓存做的开发测试,在线程中打开数据库查询数据,及关闭数据库后查询数据的结果.
SpringMVC+Spring4.2+hibernate4.3+shiro1.2.4+ehcache2.0所需jar包,非常有用,你可能会需要。
Spring Boot中使用EhCache实现缓存支持,介绍整合方法和配置
mybatis ehcache 整合中文文档 mybatis ehcache 整合中文文档 mybatis ehcache 整合中文文档
shiro-demo使用ehcache做缓存.zip
Ehcache API,页面缓存,分布式缓存。
赠送jar包:ehcache-3.3.1.jar; 赠送原API文档:ehcache-3.3.1-javadoc.jar; 赠送源代码:ehcache-3.3.1-sources.jar;...人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心使用。
SpringBoo2.x整合Ehcache3.x作为缓存底层存储。
将以下配置copy的ehcache.xml文件的ehcache标签中,注:上述链接中说的配置少写了个probe包名。 , monitorPor t=9889" /> 3.在\ehcache-monitor-kit-1.0.0\etc\ehcache-monitor.conf中可以配置监控的ip和端口号。 4....
Ehcache使用: CacheManager主要的缓存管理类,一般一个应用为一个实例,如下 CacheManager.create();也可以使用new CacheManager的方式创建 默认的配置文件为ehcache.xml文件,也可以使用不同的配置: ...
EhCache使用详解,HIBERNATE缓冲
cache、ehcache等缓存使用,实现存对象读对象等等
EhCache 是一个纯 Java 的进程内缓存框架,具有快速、精干等特点,是 Hibernate 中默认的 CacheProvider。这篇文章主要介绍了SpringBoot中使用Ehcache的相关知识,需要的朋友可以参考下
Ehcache经典中文教程Ehcache内存框架介绍 —高成勇 安装 配置 编码接口介绍 api
ehcache配置使用详解,里面有具体的例子
软件仍然是开源,但一些新的主要功能(例如,快速可重启性之间的一致性的)只能在商业产品中使用,例如Enterprise EHCache and BigMemory。,维基媒体Foundationannounced目前使用的就是Ehcache技术。
主要介绍了SpringBoot中Shiro缓存使用Redis、Ehcache的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧