单独配置 Ehcache
package com.shy.ehcache; import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element; public class EhcacheDemo { public static void main(String[] args) { //加载配置文件路径为:src/config/ehcache.xml
CacheManager manager = CacheManager.create("src/config/ehcache.xml");
//获取全部缓存名称
String[] names = manager.getCacheNames();
//打印缓存名称
for(String name : names){
System.out.println("ehcache names = "+name);
}
//获取指定的cache
Cache cache = manager.getCache(names[0]);
//创建一个内存元素
Element e = new Element("sayHello", "hello");
//将元素放入内存
cache.put(e);
//从内存读取
System.out.println(cache.get("sayHello")); } }
单独配置 Ehcache的更多相关文章
- 在 JPA、Hibernate 和 Spring 中配置 Ehcache 缓存
jpa, hibernate 和 spring 时配置 ehcache 二级缓存的步骤. 缓存配置 首先在 persistence.xml 配置文件中添加下面内容: <property name ...
- php-fpm 重启 nginx单独配置 重启
nginx单独配置 重启 [root@ssy106c14c190c69 Api]# cd /usr/local/nginx/sbin/[root@ssy106c14c190c69 sbin]# lsn ...
- Hibernate JPA 中配置Ehcache二级缓存
在Hibernate3 JPA里配置了一下非分布式环境的二级缓存,效果不错.具体过程如下: 1, 需要引入的jar包 http://ehcache.org/downloads/catalog 下载的包 ...
- Spring自定义缓存管理及配置Ehcache缓存
spring自带缓存.自建缓存管理器等都可解决项目部分性能问题.结合Ehcache后性能更优,使用也比较简单. 在进行Ehcache学习之前,最好对Spring自带的缓存管理有一个总体的认识. 这篇文 ...
- 缓存初解(四)---Ibatis的缓存配置+Ehcache
项目完结,整理一些技术方面的相关收获. 已经记不得EhCacheController这个实现类最早来自于那里了,总之稍加修改后非常有效果,大家就这么用了,感谢最初开源的那位兄弟.这里,主要是做个记录, ...
- 缓存初解(三)---Spring3.0基于注解的缓存配置+Ehcache和OScache
本文将构建一个普通工程来说明spring注解缓存的使用方式,关于如何在web应用中使用注解缓存,请参见: Spring基于注解的缓存配置--web应用实例 一.简介 在spring的modules包中 ...
- 快速配置Ehcache
1. 编写ehcache.xml文件,将该文件放置于classpath路径下.代码如下: <?xml version="1.0" encoding="UTF-8&q ...
- 每个项目单独配置 git 用户
git多账号登陆问题 设置git全局设置: git config --global user.name "your_name" git config --global user. ...
- mybatis配置ehcache缓存
1:在spring配置文件中加载缓存配置文件 <!-- 使用ehcache缓存 --> <bean id="ehCacheManager" class=" ...
随机推荐
- 【数组】Minimum Size Subarray Sum
题目: Given an array of n positive integers and a positive integer s, find the minimal length of a sub ...
- Oracle 中分组排序取值的问题
整理一下排序: 建表语句:create table EXAM( name VARCHAR2(32), subject VARCHAR2(32), score INTEGER)数据:IN ...
- Android 开发服务类 01_ServletForXML
Servlet implementation class NewsListServlet package com.wangjialin.server.xml; import java.io.IOExc ...
- Python基础语法——(引号、字符串、长字符串、原始字符串、Unicode)
一.单引号字符串和转义引号 当字符串中出现单引号'时,我们可以用双引号""将该字符串引起来:"Let's go!" 而当字符串中出现双引号时,我们可以用单引号' ...
- Types方法之upperBound-lowerBound-isUnbounded-containsType
1.upperBound(Type t)方法 /** * The "rvalue conversion". * The upper bound of most types is t ...
- Chapter 3 Phenomenon——7
"Bella? Are you all right?" “贝拉?你还好吗?” "I'm fine." My voice sounded strange. “我还 ...
- kibana加访问控制时报错--Kibana did not load properly.Check the server output for more information.
错误 在使用kibana的时候,我们需要对可以进行日志访问进行控制,x-pack插件是最好的选择,但是kibana的x-pack插件是收费的,我们本着节约资源的理念(公司的钱也是钱啊,哈哈),我决定使 ...
- 8-lvs-负载均衡
注意: linux集群的时间需要一致 并发量在千万以上, 一般才会使用此种方式, 基于第四层进行ip欺骗, 使得nginx只接受上行流量, 下行流量通过具体执行的服务器直接返回 由章文嵩博士(淘宝) ...
- Servlet多文件上传方法
1. 通过getInputStream()取得上传文件. 001 /** 002 * To change this template, choose Tools | Templates 003 * ...
- JavaScript函数——预编译
四部曲 创建AO对象 找形参和变量声明,将变量和形参名作为AO属性名,值为undefined. 将实参值和形参值统一 在函数体内找函数声明,值赋予函数体. 权重按顺序依次增加.以下例子即可体现上述规则 ...