Ehcache的配置与使用
Ehcache是JAVA内制的一个缓存框架!
目的:缓解频繁读取数据库的压力;
初步配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache updateCheck="false" name="shirocache">
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="10000"
maxElementsOnDisk="0"
eternal="true"
overflowToDisk="true"
diskPersistent="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
diskSpoolBufferSizeMB="50"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LFU"
/>
<cache name="shiro_cache"
maxElementsInMemory="2000"
maxEntriesLocalHeap="2000"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
maxElementsOnDisk="0"
overflowToDisk="true"
memoryStoreEvictionPolicy="FIFO"
statistics="true">
</cache>
</ehcache>
使用如下:
1、存储数据;
CacheManager cacheManager = CacheManager.create(url);
Cache cache=cacheManager.getCache("shiro_cache");
Element element = new Element("pwd", password);
cache.put(element);
2、读取数据
URL url = getClass().getResource("/ehcache/ehcache.xml");
CacheManager cacheManager = CacheManager.create(url);
Cache cache=cacheManager.getCache("shiro_cache");
Element element = cache.get("pwd");
System.out.println(element.toString());
Ehcache的配置与使用的更多相关文章
- (转)springMVC+mybatis+ehcache详细配置
一. Mybatis+Ehcache配置 为了提高MyBatis的性能,有时候我们需要加入缓存支持,目前用的比较多的缓存莫过于ehcache缓存了,ehcache性能强大,而且位各种应用都提供了解决方 ...
- ehcache.xml配置参数
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLoc ...
- hibernate二级缓存ehcache hibernate配置详解
<!-----------------hibernate二级缓存ehcache------------------------->hibernate配置 <prop key=&quo ...
- spring中ehcache的配置和使用方法
继续上篇,这篇介绍服务层缓存,ehcache一般的配置和用法 一.添加jar包引用 修改pom.xml文件,加入: <dependency> <groupId>org.spri ...
- SpringBoot中整合Redis、Ehcache使用配置切换 并且整合到Shiro中
在SpringBoot中Shiro缓存使用Redis.Ehcache实现的两种方式实例 SpringBoot 中配置redis作为session 缓存器. 让shiro引用 本文是建立在你是使用这sh ...
- EhCache的配置
JPA和Hibernate的二级缓存都是这样做的 代码目录: 这是基础的jar包,如果少的话,再去maven下载 <!-- Spring --> <dependency> &l ...
- Ehcache缓存配置
Cache的配置很灵活,官方提供的Cache配置方式有好几种.你可以通过声明配置.在xml中配置.在程序里配置或者调用构造方法时传入不同的参数. 你可以将Cache的配置从代码中剥离出来,也可以在使用 ...
- Hibernate学习笔记之EHCache的配置
Hibernate默认二级缓存是不启动的,启动二级缓存(以EHCache为例)需要以下步骤: 1.添加相关的包: Ehcache.jar和commons-logging.jar,如果hibernate ...
- ehcache 的配置
配置:一.在src目录下加入ehcache.xml: <cache name="SimplePageCachingFilter" maxElementsInMemory=&q ...
- 02_MyBatis项目结构,所需jar包,ehcache.xml配置,log4j.properties,sqlMapConfig.xml配置,SqlMapGenerator.xml配置
项目结构(所需jar包,配置文件) sqlMapConfig.xml的配置内容如下: <?xmlversion="1.0"encoding="UTF-8&qu ...
随机推荐
- Mineweep(扫雷)
题目描述: 每周一题之2 Mineweep(扫雷) Minesweeper (扫雷) PC/UVa IDs: 110102/10189, Popularity: A, Success rate: h ...
- pycharm、idea 2018软件安装教程
Python3.7安装: https://www.jb51.net/article/146326.htm pycharm软件: https://www.jianshu.com/p/cf77d74bef ...
- 读经典——《CLR via C#》(Jeffrey Richter著) 笔记_CLR
1.CLR简介 全称:Common Language Runtime(公共语言进行时) 属性:一种托管模块 使用对象:面向CLR的所有语言(C#.Basic.IL...) 核心功能:内存管理.程序集加 ...
- P3166 [CQOI2014]数三角形
传送门 直接求还要考虑各种不合法情况,不好计数 很容易想到容斥 把所有可能减去不合法的情况剩下的就是合法情况 那么我们只要任取不同的三点就是所有可能,不合法情况就是三点共线 对于两点 $(x_1,y_ ...
- UVA 10806
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> us ...
- Java缓存类loadingCache
<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artif ...
- msyql操作100题
1.1.1 开启MySQL服务 /etc/init.d/mysqld start 使用/etc/init.d/mysqld start命令启动数据库的本质就相当于执行mysqld_safe --use ...
- Java发送http请求(get 与post方法请求)
转载:https://www.cnblogs.com/zzw1994/p/5140538.html
- jquery插件分页
收藏地址: http://www.jq22.com/yanshi5697
- Deep Visualization:可视化并理解CNN(转)
转载地址:https://zhuanlan.zhihu.com/p/24833574 一.前言 CNN作为一个著名的深度学习领域的“黑盒”模型,已经在计算机视觉的诸多领域取得了极大的成功,但是,至今没 ...