如何在grails shiro中使用缓存权限 [英] how to use cache permissions in grails shiro
问题描述
如何缓存它?
任何示例?谢谢
我读过了shiro grails插件的文档。但不能解决它。
数据源:
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class ='net.sf.ehcache.hibernate.EhCacheProvider'
}
那么如何将cachemanager设置为shiro?我尝试spring.resource,抛出一个错误。
以及cachemanager的实例bean名称是什么?我需要配置其他的?
您需要配置一个org.apache.shiro.cache.CacheManager实例在Shiro的SecurityManager上。 Shiro的大部分开箱即用Realm实现知道如何使用配置的CacheManager,并自动缓存从Realm权限查询返回的AuthorizationInfo。
我是不知道如何使用Grails Shiro插件来做到这一点,但在Shiro的INI中,您可以这样做:
[main ]
...
cacheManager = com.my.implementation.of.CacheManager
securityManager.cacheManager = $ cacheManager
...
我建议您问一下grails-user邮件列表,看看Grails Shiro插件是否有更多'grailsy'的配置方式。
HTH,
Les
everytime i call subject.isPermitted(), it send a sql to db. how can i cache it?
any example? thanks
i had read the doc of shiro grails plugin. but cant solove it.
DataSource:
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
then how to set the cachemanager to shiro? i try spring.resource,throw an error.
and what's the instance bean name of cachemanager? do i need to config sth else?
You'll need to configure an org.apache.shiro.cache.CacheManager instance on Shiro's SecurityManager. Most of Shiro's out-of-the-box Realm implementations know how to work with a configured CacheManager and will cache AuthorizationInfo returned from a Realm permission lookup automatically.
I'm not sure how to do this using the Grails Shiro plugin, but in Shiro's INI, you would do that this way:
[main]
...
cacheManager = com.my.implementation.of.CacheManager
securityManager.cacheManager = $cacheManager
...
I'd recommend asking the grails-user mailing list to see if there is a more 'grailsy' way to configure this for the Grails Shiro plugin.
HTH,
Les
这篇关于如何在grails shiro中使用缓存权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!