`
Technoboy
  • 浏览: 153799 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

Shiro User Manual-Caching

阅读更多
1. Caching
Shiro团队了解性能的重要性,因此,缓存被作为一个重要的特性纳入到安全操作中。

2. Caching API
Shiro有3个重要的缓存接口:
a. CacheManager 缓存的管理组件,它返回Cache实例。
b. Cache  维护键值对形式的缓存
c. CacheManagerAware  一个接口,由想获得和使用CacheManager的组件实现。
CacheManager返回Cache实例,不同的Shiro组件使用这些Cache缓存数据。实现了CacheManagerAware接口的组件将获得CacheManager,并进一步通过CacheManager获取Cache。
SecurityManager,AuthenticatingRealm,以及AuthorizingRealm,他们默认都实现了CacheManagerAware接口。如果把CacheManager设置到SecurityManager属性里,所有实现了CacheManagerAware的Realm都将获取到CacheManager实例。
securityManager.realms = $myRealm1, $myRealm2, ..., $myRealmN
...
cacheManager = my.implementation.of.CacheManager
...
securityManager.cacheManager = $cacheManager
# at this point, the securityManager and all CacheManagerAware
# realms have been set with the cacheManager instance


3. CacheManager Implementations
Shiro提供了一系列的CacheManager实现以满足你的需求。

3.1 MemoryConstrainedCacheManager
MemoryConstrainedCacheManager是一个基于单JVM的CacheManager实现,它不支持分布式或集群,如果你的应用部署在多JVM上(比如,web应用部署在多台服务器上),且想在JVM间进行缓存的访问,你需要使用分布式缓存实现。
MemoryConstrainedCacheManager管理多个MapCache实例,一个命名的缓存即为一个MapCache实例。每一个MapCache都提供了SoftHashMap,它基于应用程序运行时内存约束和需求,可以自动调整大小的(通过利用JDK的SoftReference)。
由于MemoryConstrainedCacheManager可以基于应用配置文件自动调整自身大小,因此其可以在单JVM的生产环境和测试中使用。但是,它不支持那些高级的特性,比如设置存活时间,过期时间等设置。在INI文件中配置:
...
cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
...
securityManager.cacheManager = $cacheManager


3.2 HazelcastCacheManager
当前版本不支持HazelcastCacheManager, 将在1.3版本中出现。
分享到:
评论

相关推荐

    shiro(shiro-all-1.8.0.jar)

    shiro(shiro-all-1.8.0.jar)

    shiro-core-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-core-1.4.0.jar; 赠送原API文档:shiro-core-1.4.0-javadoc.jar; 赠送源代码:shiro-core-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-core-1.4.0.pom; 包含翻译后的API文档:shiro-core...

    shiro-config-core-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-config-core-1.4.0.jar; 赠送原API文档:shiro-config-core-1.4.0-javadoc.jar; 赠送源代码:shiro-config-core-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-config-core-1.4.0.pom; ...

    shiro-ehcache-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-ehcache-1.4.0.jar; 赠送原API文档:shiro-ehcache-1.4.0-javadoc.jar; 赠送源代码:shiro-ehcache-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-ehcache-1.4.0.pom; 包含翻译后的API文档...

    shiro-jar-1.7.0.zip相关资源包

    解决:升級1.7后附件...shiro-cas-1.7.0.jar shiro-core-1.7.0.jar shiro-ehcache-1.7.0.jar shiro-spring-1.7.0.jar shiro-web-1.7.0.jar CustomShiroFilterFactoryBean.java spring-context-shiro.xml 修改说明.txt

    shiro-crypto-cipher-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-crypto-cipher-1.4.0.jar; 赠送原API文档:shiro-crypto-cipher-1.4.0-javadoc.jar; 赠送源代码:shiro-crypto-cipher-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-crypto-cipher-1.4.0....

    shiro-crypto-core-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-crypto-core-1.4.0.jar; 赠送原API文档:shiro-crypto-core-1.4.0-javadoc.jar; 赠送源代码:shiro-crypto-core-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-crypto-core-1.4.0.pom; ...

    shiro-crypto-core-1.4.0-API文档-中英对照版.zip

    赠送jar包:shiro-crypto-core-1.4.0.jar; 赠送原API文档:shiro-crypto-core-1.4.0-javadoc.jar; 赠送源代码:shiro-crypto-core-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-crypto-core-1.4.0.pom; ...

    shiro-cas-1.2.3-API文档-中文版.zip

    赠送jar包:shiro-cas-1.2.3.jar; 赠送原API文档:shiro-cas-1.2.3-javadoc.jar; 赠送源代码:shiro-cas-1.2.3-sources.jar; 赠送Maven依赖信息文件:shiro-cas-1.2.3.pom; 包含翻译后的API文档:shiro-cas-...

    shiro-config-core-1.4.0-API文档-中英对照版.zip

    赠送jar包:shiro-config-core-1.4.0.jar; 赠送原API文档:shiro-config-core-1.4.0-javadoc.jar; 赠送源代码:shiro-config-core-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-config-core-1.4.0.pom; ...

    shiro-config-ogdl-1.4.0-API文档-中英对照版.zip

    赠送jar包:shiro-config-ogdl-1.4.0.jar; 赠送原API文档:shiro-config-ogdl-1.4.0-javadoc.jar; 赠送源代码:shiro-config-ogdl-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-config-ogdl-1.4.0.pom; ...

    shiro-cas-1.2.3-API文档-中英对照版.zip

    赠送jar包:shiro-cas-1.2.3.jar; 赠送原API文档:shiro-cas-1.2.3-javadoc.jar; 赠送源代码:shiro-cas-1.2.3-sources.jar; 赠送Maven依赖信息文件:shiro-cas-1.2.3.pom; 包含翻译后的API文档:shiro-cas-...

    shiro-cache-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-cache-1.4.0.jar; 赠送原API文档:shiro-cache-1.4.0-javadoc.jar; 赠送源代码:shiro-cache-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-cache-1.4.0.pom; 包含翻译后的API文档:shiro-...

    shiro-core-1.7.1 jar

    shiro shiro-core-1.7.1 jar shiro漏洞

    shiro-attack-4.7.0-SNAPSHOT-all.zip

    shiro_attack-4.7.0-SNAPSHOT-all.zip 序列化验证工具

    shiro-cache-1.4.0-API文档-中英对照版.zip

    赠送jar包:shiro-cache-1.4.0.jar; 赠送原API文档:shiro-cache-1.4.0-javadoc.jar; 赠送源代码:shiro-cache-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-cache-1.4.0.pom; 包含翻译后的API文档:shiro-...

    shiro-all-1.3.2.jar

    shiro-all-1.3.2.jar

    shiro-event-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-event-1.4.0.jar; 赠送原API文档:shiro-event-1.4.0-javadoc.jar; 赠送源代码:shiro-event-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-event-1.4.0.pom; 包含翻译后的API文档:shiro-...

    shiro-root-1.4.1-source-release.zip

    给广大开发爱好者一个开发框架:shiro-root-1.4.1-source-release.zip

    SpringMVC-Mybatis-Shiro-redis-master

    SpringMVC-Mybatis-Shiro-redis-master..............

Global site tag (gtag.js) - Google Analytics