开发者

How to use cache permissions in grails shiro

Everytime i call subject.isPermitted(), it sends a sql to db.

How can i cache it? Any example? Thanks.


I 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'
}

How to set the cachemanager to shiro? I try spring.resource,throw an error.

What's the instance bean na开发者_开发百科me 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜