You could use CachingRealm.clearCache, it is protected, but that could be an option if you are subclassing https://github.com/apache/shiro/blob/1.2.x/core/src/main/java/org/apache/shiro/realm/CachingRealm.java#L164
You could also access the CacheManager directly, and clear all the cache, but that is a bit heavy handed. On Tue, Sep 15, 2015 at 11:53 AM, Silo <[email protected]> wrote: > I've configured a salted JDBC realm and a hazelcast cache. It seems to be > working just fine with one exception — newly defined roles in the DB are > not > recognized by shiro. My guess is that this has something to do with the > subject/session/role being cached but not being updated when the DB > changes. > I would like to make DB changes outside of the shiro app. What is the best > way to insure my cache is updated with changes made in the DB? > > My steps are this: > 1) Create a new session by logging in using a user's credentials. > 2) Ask shiro if the user has a defined role. It answers that the user does > indeed have the role. > 3) Add a new role for that user in the DB. > 4) Ask shiro if the user has the new role. It answers that the user does > not > have the role. > > Restarting the shiro app will fix the problem. > > > > -- > View this message in context: > http://shiro-user.582556.n2.nabble.com/Stale-Roles-when-using-JDBC-realm-and-hazelcast-cache-tp7580759.html > Sent from the Shiro User mailing list archive at Nabble.com. >
