Shiro在Spring中的缓存配置
来源:互联网 发布:ubuntu翻译软件 编辑:程序博客网 时间:2024/06/05 17:25
1、开发环境
①、spring开发环境配置
②、shiro相关开发环境配置
http://blog.csdn.net/u012737182/article/details/53002281
在此基础上再增加shiro的缓存组件包
<dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-ehcache</artifactId> <version>1.3.0</version> </dependency>
2、定义相应的缓存配置文件
<?xml version="1.1" encoding="UTF-8"?><ehcache name="shirocache"> <diskStore path="java.io.tmpdir"/> <defaultCache maxElementsInMemory="2000" eternal="true" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"/> <cache name="passwordRetryCache" maxElementsInMemory="2000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="0" overflowToDisk="false"> </cache> <cache name="authorizationCache" maxElementsInMemory="2000" eternal="false" timeToIdleSeconds="1800" timeToLiveSeconds="0" overflowToDisk="false"> </cache> <cache name="authenticationCache" maxElementsInMemory="2000" eternal="false" timeToIdleSeconds="1800" timeToLiveSeconds="0" overflowToDisk="false"> </cache> <cache name="shiro-activeSessionCache" maxElementsInMemory="2000" eternal="false" timeToIdleSeconds="1800" timeToLiveSeconds="0" overflowToDisk="false"> </cache></ehcache>
在此配置文件之中实际上有以下几个核心选项:
“diskStore path=”java.io.tmpdir”:磁盘的存储目录;
“name=”xxx””:对要进行缓存的项进行一个标注;
“maxElementsInMemory=”2000”:可以缓存的最大的对象个数;
“eternal=”false”:是否允许自动失效(如果某一个对象长时间不使用);
“timeToIdleSeconds=”1800”:最小的失效时间,1800秒;
“timeToLiveSeconds=”0”:最大的保存时间,单位是秒;
“overflowToDisk=”false”:如果容量过多,可以将其保存在磁盘
3、如果要想使缓存生效,则还需要修改applicationContext.xml文件进行缓存配置:
· 定义缓存管理器:
<!-- 进行缓存的操作配置 --> <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager"> <property name="cacheManagerConfigFile" value="classpath:ehcache.xml"/> </bean>
在安全管理器之中注册此缓存管理器:
<!-- 配置SecurityManager的管理 --> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <!-- 配置你需要使用的Realms --> <property name="realm" ref="memberRealm"/> <property name="cacheManager" ref="cacheManager"/> </bean>
0 0
- Shiro在Spring中的缓存配置
- shiro 在spring中的配置
- 在Spring中配置Shiro
- shiro中的缓存的配置与使用
- shiro在Spring MVC + hibernate 中配置
- Spring-data-redis在shiro中的实例
- Shiro在strust2+spring中的应用
- Shiro EHCache缓存配置
- shiro缓存配置
- CAS和Shiro在spring中集成+Hibernate缓存优化
- spring+springmvc+shiro配置
- spring shiro配置
- shiro+spring相关配置
- spring+shiro 配置使用
- spring mvc shiro 配置
- spring shiro 配置详解
- shiro配置----spring.xml
- Spring在配置Shiro 关于AOP的部分记录
- 微信小程序7---image组件
- 二叉搜索树(BST)的删除算法原理解析
- leetcode——Non-overlapping Intervals
- http协议
- 16年11月03问题汇总
- Shiro在Spring中的缓存配置
- 1.js判断浏览器版本或类型
- nginx配置:反向代理 负载均衡 后端健康检查 缓存
- Activity跳转的几种方式
- onKeyDown事件,设置按返回键间隔不超过两秒时退出程序问题
- hdu 1050
- jQuery构造器
- Leetcode
- CSDN-markdown语法——缩进、图片居中、字体、字号与颜色