缓存技术内部交流_02_Ehcache3 XML 配置
参考资料:
http://www.ehcache.org/documentation/3.2/getting-started.html#configuring-with-xml
http://www.ehcache.org/documentation/3.2/xml.html
示例代码:
https://github.com/gordonklg/study,cache module
A. 实例
gordon.study.cache.ehcache3.basic.XmlConfig.java
public class XmlConfig {
public static void main(String[] args) {
final URL myUrl = XmlConfig.class.getResource("/ehcache3_basic.xml");
Configuration xmlConfig = new XmlConfiguration(myUrl);
CacheManager cacheManager = CacheManagerBuilder.newCacheManager(xmlConfig);
cacheManager.init();
Cache<String, UserModel> phoneUserCache = cacheManager.getCache("phoneUserCache", String.class, UserModel.class);
UserModel user = new UserModel("13316619988", "abc@123.com", "openid12345", "very very long user information ...");
phoneUserCache.put(user.getPhone(), user);
UserModel cached = phoneUserCache.get(user.getPhone());
System.out.println(cached.getInfo());
}
}
示例代码简单明了,没啥好说的。
ehcache3_basic.xml in src/main/resources
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3' xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
xsi:schemaLocation="
http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.2.xsd
http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.2.xsd">
<cache-template name="userTemplate">
<key-type>java.lang.String</key-type>
<value-type>gordon.study.cache.ehcache3.basic.UserModel</value-type>
<heap unit="entries">5</heap>
</cache-template>
<cache alias="phoneUserCache" uses-template="userTemplate">
<heap unit="entries">20</heap>
</cache>
<cache alias="emailUserCache" uses-template="userTemplate" />
</config>
配置文件同样简单明了。其中 cache-template 为缓存模板,可以简化配置。
缓存技术内部交流_02_Ehcache3 XML 配置的更多相关文章
- 缓存技术内部交流_05_Cache Through
参考资料: http://www.ehcache.org/documentation/3.2/caching-patterns.html http://www.ehcache.org/document ...
- 缓存技术内部交流_04_Cache Aside续篇
额外参考资料: http://www.ehcache.org/documentation/3.2/expiry.html F. Cache Aside 模式的问题:缓存过期 有时我们会在上线前给缓存系 ...
- 缓存技术内部交流_01_Ehcache3简介
参考资料: http://www.ehcache.org/documentation/3.2/getting-started.html http://www.ehcache.org/documenta ...
- 缓存技术内部交流_03_Cache Aside
参考资料: http://www.ehcache.org/documentation/3.2/caching-patterns.html http://www.ehcache.org/document ...
- ASP.NET Core 缓存技术 及 Nginx 缓存配置
前言 在Asp.Net Core Nginx部署一文中,主要是讲述的如何利用Nginx来实现应用程序的部署,使用Nginx来部署主要有两大好处,第一是利用Nginx的负载均衡功能,第二是使用Nginx ...
- Smarty的配置与高级缓存技术
转之--http://www.cnblogs.com/-run/archive/2012/06/04/2532801.html Smarty 是一个出色的PHP模板引擎,它分离了逻辑代码和user i ...
- .Net环境下的缓存技术介绍 (转)
.Net环境下的缓存技术介绍 (转) 摘要:介绍缓存的基本概念和常用的缓存技术,给出了各种技术的实现机制的简单介绍和适用范围说明,以及设计缓存方案应该考虑的问题(共17页) 1 概念 ...
- .Net环境下的缓存技术介绍
.Net环境下的缓存技术介绍 摘要: 介绍缓存的基本概念和常用的缓存技术,给出了各种技术的实现机制的简单介绍和适用范围说明,以及设计缓存方案应该考虑的问题(共17页) 1 概念 1.1 ...
- ASP.NET 缓存技术分析
缓存功能是大型网站设计一个很重要的部分.由数据库驱动的Web应用程序,如果需要改善其性能,最好的方法是使用缓存功能.可能的情况下尽量使用缓存,从内存中返回数据的速度始终比去数据库查的速度快,因而可以大 ...
随机推荐
- 一个父亲的教育札记——leo鉴书58
由于年纪和工作的原因.绝大部分小说我都不看--没空,如今小说写的也太空.但对文笔有提高的文章我是非常关注的,知道韩寒不是由于<三重门>(我报纸也不怎么看).而是此前编辑感觉我文笔差. ...
- 检查Linux服务器性能命令详解
如果你的Linux服务器突然负载暴增,如何在最短时间内找出Linux性能问题所在? 通过执行以下命令,可以在1分钟内对系统资源使用情况有个大致的了解. uptime dmesg | tail vmst ...
- 机器学习第2周---炼数成金-----线性回归与Logistic
重点归纳 回归分析就是利用样本(已知数据),产生拟合方程,从而(对未知数据)迚行预测用途:预测,判别合理性例子:利用身高预测体重:利用广告费用预测商品销售额:等等.线性回归分析:一元线性:多元线性:广 ...
- iOS学习之HelloWorld工程
本文应读者要求,主要简介使用Xcode创建一个“HelloWorld”工程. 1.打开Xcode,点击新建工程 选择工程类型 2.填写工程信息 3.代码简介 // // main.m // hello ...
- Get started on your own KD 8 custom colorway
The 2009 Summer time Nike Basketball revealed the Cheap KD 8 and revealed three MVP-inspired colors ...
- python中变量的交换
a=4 b=5 #第一种 c=0 c=a a=b b=c print('a=%d,b=%d'%(a,b)) #第二种 a=a+b b=a-b a=a-b print('a=%d,b=%d'%(a,b) ...
- webpack.dev.conf.js详解
转载自:https://www.cnblogs.com/ye-hcj/p/7087205.html webpack.dev.conf.js详解 //引入当前目录下的utils.js文件模块var ut ...
- TortoiseSVN_1.9.1.267_x64版本控制系统(针对Visual SVN Server)使用简单介绍
软件下载地址:TortoiseSVN(SVN客户端)64位 V1.9.1.267简体中文免费版 软件详细操作说明:TortoiseSVN使用说明书(超详细) 文章内容:此篇是简单记录如何从Visual ...
- Laravel 学习记录
1.当配置 根目录没有指向/public 时 去掉www.blog.im/public 后的文件 需要把 public 文件夹里的..htaccess 文件放到 项目根目录.server.ph ...
- adb常用操作
1.安装程序 adb -s serialno install -r path 2.切换电源 adb -s serialno shell input keyevent 26 3.主页键 adb -s s ...