ehcache缓存使用
CacheUtils.java //工具类
保存cache缓存:
CacheUtils.put(CacheUtils.SIGN_CACHE, childid + "_" + mNum, signatureData);
取缓存:
//public static Object get(String cacheName, String key)
Object signObj = CacheUtils.get(CacheUtils.SIGN_CACHE, childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
String signStr = (String) signObj;//再将Object对象强转为字符串
删除缓存:
CacheUtils.remove(CacheUtils.SIGN_CACHE, childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.thinkgem.jeesite.common.utils; import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element; /**
* Cache工具类
* @author ThinkGem
* @version 2013-5-29
*/
public class CacheUtils { private static CacheManager cacheManager = ((CacheManager)SpringContextHolder.getBean("cacheManager")); private static final String SYS_CACHE = "sysCache";
public static final String SIGN_CACHE = "signCache";
public static final String COLD_CACHE ="coldCache"; /**
* 获取SYS_CACHE缓存
* @param key
* @return
*/
public static Object get(String key) {
return get(SYS_CACHE, key);
} /**
* 写入SYS_CACHE缓存
* @param key
* @return
*/
public static void put(String key, Object value) {
put(SYS_CACHE, key, value);
} /**
* 从SYS_CACHE缓存中移除
* @param key
* @return
*/
public static void remove(String key) {
remove(SYS_CACHE, key);
} /**
* 获取缓存
* @param cacheName
* @param key
* @return
*/
public static Object get(String cacheName, String key) {
Element element = getCache(cacheName).get(key);
return element==null?null:element.getObjectValue();
} /**
* 写入缓存
* @param cacheName
* @param key
* @param value
*/
public static void put(String cacheName, String key, Object value) {
Element element = new Element(key, value);
getCache(cacheName).put(element);
} /**
* 从缓存中移除
* @param cacheName
* @param key
*/
public static void remove(String cacheName, String key) {
getCache(cacheName).remove(key);
} /**
* 获得一个Cache,没有则创建一个。
* @param cacheName
* @return
*/
private static Cache getCache(String cacheName){
Cache cache = cacheManager.getCache(cacheName);
if (cache == null){
cacheManager.addCache(cacheName);
cache = cacheManager.getCache(cacheName);
cache.getCacheConfiguration().setEternal(true);
}
return cache;
} public static CacheManager getCacheManager() {
return cacheManager;
} }
签字缓存保存位置:

ehcache缓存使用的更多相关文章
- [原创]mybatis中整合ehcache缓存框架的使用
mybatis整合ehcache缓存框架的使用 mybaits的二级缓存是mapper范围级别,除了在SqlMapConfig.xml设置二级缓存的总开关,还要在具体的mapper.xml中开启二级缓 ...
- 深入探讨在集群环境中使用 EhCache 缓存系统
EhCache 缓存系统简介 EhCache 是一个纯 Java 的进程内缓存框架,具有快速.精干等特点,是 Hibernate 中默认的 CacheProvider. 下图是 EhCache 在应用 ...
- EhCache缓存
EhCache缓存 EhCache 是一个纯Java的进程内缓存框架,具有快速.精干等特点,是Hibernate中默认的CacheProvider. Ehcache是一种广泛使用的开源Java分布式缓 ...
- 我们究竟什么时候可以使用Ehcache缓存
一.Ehcache是什么 EhCache是Hibernate的二级缓存技术之一,可以把查询出来的数据存储在内存或者磁盘,节省下次同样查询语句再次查询数据库,大幅减轻数据库压力. 二.Ehcache的使 ...
- mybatis0210 mybatis和ehcache缓存框架整合
.1mybatis和ehcache缓存框架整合 一般不用mybatis来管理缓存而是用其他缓存框架在管理缓存,因为其他缓存框架管理缓存会更加高效,因为别人专业做缓存的而mybatis专业做sql语句的 ...
- (转)深入探讨在集群环境中使用 EhCache 缓存系统
简介: EhCache 是一个纯 Java 的进程内缓存框架,具有快速.精干等特点,是 Hibernate 中默认的 CacheProvider.本文充分的介绍了 EhCache 缓存系统对集群环境的 ...
- 我们究竟什么时候可以使用Ehcache缓存(转)
一.Ehcache是什么 EhCache是Hibernate的二级缓存技术之一,可以把查询出来的数据存储在内存或者磁盘,节省下次同样查询语句再次查询数据库,大幅减轻数据库压力. 二.Ehcache的使 ...
- JAVAEE——BOS物流项目12:角色、用户管理,使用ehcache缓存,系统菜单根据登录人展示
1 学习计划 1.角色管理 n 添加角色功能 n 角色分页查询 2.用户管理 n 添加用户功能 n 用户分页查询 3.修改Realm中授权方法(查询数据库) 4.使用ehcache缓存权限数据 n 添 ...
- Shiro入门之二 --------基于注解方式的权限控制与Ehcache缓存
一 基于注解方式的权限控制 首先, 在spring配置文件applicationContext.xml中配置自动代理和切面 <!-- 8配置自动代理 --> <bean cl ...
- Springboot整合Ehcache缓存
Pom.xml导包 <!-- ehcache --> <dependency> <groupId>org.springframework.boot</grou ...
随机推荐
- Jquery 字符串转数字
其实在jquery里把字符串转换为数字,用的还是js,因为jquery本身就是用js封装编写的. 比如我们在用jquery里的ajax来更新文章的阅读次数或人气的时候,就需要用到字符串转换为数字的功能 ...
- tensorflow 升级到1.9-rc0,生成静态图frozen graph.pb本地测试正常, 在其他版本(eg1.4版本)或者android下运行出错NodeDef mentions attr 'dilations' not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_
这时节点定义找不到NodeDef attr 'dilations' not in,说明执行版本的NodeDef不在节点定义上,两个不一致,分别是执行inference的代码和生成静态图节点不一致(当然 ...
- CSS 图像左右对齐
左右对齐图像使用的技术是浮动div元素. float:left 左对齐 float:right右对齐 示例 <!DOCTYPE html> <html> <hea ...
- PhoenixFD插件流体模拟——UI布局【Gird】详解
流体网格 本文主要讲解Grid折叠栏中的内容 主要内容 Overview 综述 Parameters 参数 General 普通参数 Example: Scene Scale Example: Gri ...
- Cocos2dx开发之运行与渲染流程分析
学习Cocos2dx,我们都知道程序是由 AppDelegate 的方法 applicationDidFinishLaunching 开始,在其中做些必要的初始化,并创建运行第一个 CCScene 即 ...
- Beautiful Numbers(牛客网)
链接:https://ac.nowcoder.com/acm/problem/17385来源:牛客网 题目描述 NIBGNAUK is an odd boy and his taste is stra ...
- 【转】JRXlsExporter.setParameter常用参数说明
net.sf.jasperreports.engine.JRExporterParameter. JASPER_PRINT 这个参数是net.sf.jasperreports.engine.Jaspe ...
- 重启虚拟机后dhclient进程未运行解决办法
问题分析 重启虚拟机后,dhclient进程未运行的根因通常为: 1.NetworkManager未开启自启动导致的dhclient进程未运行 2.网卡设置未纳入NetworkManager管理导致的 ...
- uni-app
1 路由的跳转 uni.navigateTo({ url:'/pages/home/search' }); //非tabBar页面跳转 uni.switchTab({ url:"/pages ...
- [leetcode]61. Rotate List旋转链表
Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: I ...