简体   繁体   中英

spring cache using infinispan

I want to switch between cached and non-cached mode durig run time. I know this is possible by removing the tag. But that needs a rebuild of source code/redeployment . If i found some abnormal error with infinispan cache ( timeout , or node not reachable - I am using infinispan hot rod ) , I need to switch to non-cached mode.

Is it possible to extend the spring cacheinterceptor and return null values so that application will fetch the values from DB. Basically all calls to cacheinterceptor should be ignored .

Thanks for sharing the information if any of you have done something similar.

I think there are at least 2 solutions for this problem. First, you might create your own CacheInterceptor implementation and put the switching code there. Then you would need to instruct Spring to use your custom CacheInterceptor. ProxyCachingConfiguration class might be a good place to start the investigation.

The second solution is to modify Infinispan Spring integration code and add switching functionality there. In order to achieve this you would have to override SpringRemoteCacheManagerFactoryBean , SpringRemoteCacheManager and SpringRemoteCache . I would advice putting switching code in SpringRemoteCache#get.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM