[keycloak-dev] evict on update/remove, make providers cache aware

Marek Posolda mposolda at redhat.com
Sun Nov 6 13:47:29 EST 2016


On 05/11/16 01:16, Bill Burke wrote:
> I was thinking that we change all Mongo and JPA adapters, and
> RealmProvider and UserProvider methods that can update or remove models
> from the database and have them evict the cache of that type.  This will
> make sure that if somebody gets a non-cached model or provider and
> performs an update, the cache is still invalidated.  Sound ok?
Not sure if that's good option to add this logic directly to Mongo or 
JPA providers? Mongo and JPA will contain some cache related logic, 
which is not the responsibility of these providers IMO.

IMO we can rather:
- Ensure that JPA/Mongo adapter is never returned to the caller, if the 
particular object is in cache. This may be an issue for some search 
operations (as searches are sometimes not supported by cache 
implementation), but then we can ensure that cache provider will return 
cached adapters by manually iterating over search results and make sure 
that cached adapter is returned. For example like we do for 
RealmCacheSession.getRealms() : 
https://github.com/keycloak/keycloak/blob/master/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmCacheSession.java#L442-L452

- Ensure that JPA/Mongo provider will return some decorated proxy 
object, which will decorate over JPA/Mongo adapter object and it will 
evict if set/add/update/remove method is called on this proxy? Hope we 
can somehow handle it dynamically with dynamic proxies / 
InvocationHandler like stuff.

Marek

> Thanks,
>
> Bill
>
> _______________________________________________
> keycloak-dev mailing list
> keycloak-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-dev




More information about the keycloak-dev mailing list