[jboss-user] [JBoss Cache: Core Edition] - Re: Refresh cache from cache loader on demand?

drcallaway do-not-reply at jboss.com
Thu Jun 18 22:18:41 EDT 2009

I was able to get this working with this code:

        CacheSPI cacheSpi = (CacheSPI) cache;
        CacheStoreInterceptor csi = null;
        int index = 0;

        for (Object o : cacheSpi.getInterceptorChain())
            if (o instanceof CacheStoreInterceptor)
                csi = (CacheStoreInterceptor) o;

        cacheSpi.addInterceptor(csi, index);

Basically, I remove the cache store interceptor before removing the child (this removes the local node but doesn't touch the database). I then add the interceptor back and retrieve the node. This will "refresh" the node from the database.

Of course, there are a couple problems with this code. The first is that I'm casting Cache to CacheSPI which I know is not recommended. The second is that it's pretty much a hack. Is there a more elegant way to accomplish this?


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4238644#4238644

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4238644

More information about the jboss-user mailing list