简体   繁体   English

使用infinispan的Spring缓存

[英]spring cache using infinispan

I want to switch between cached and non-cached mode durig run time. 我想在缓存和非缓存模式durig运行时之间切换。 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. 如果我发现infinispan缓存存在一些异常错误(超时或节点无法访问-我正在使用infinispan hot rod),则需要切换到非缓存模式。

Is it possible to extend the spring cacheinterceptor and return null values so that application will fetch the values from DB. 是否可以扩展spring cacheinterceptor并返回空值,以便应用程序将从DB中获取值。 Basically all calls to cacheinterceptor should be ignored . 基本上所有对cacheinterceptor的调用都应该被忽略。

Thanks for sharing the information if any of you have done something similar. 如果您有任何类似的事情,感谢您分享信息。

I think there are at least 2 solutions for this problem. 我认为至少有2个解决方案。 First, you might create your own CacheInterceptor implementation and put the switching code there. 首先,您可以创建自己的CacheInterceptor实现并将开关代码放在此处。 Then you would need to instruct Spring to use your custom CacheInterceptor. 然后,您将需要指示Spring使用您的自定义CacheInterceptor。 ProxyCachingConfiguration class might be a good place to start the investigation. ProxyCachingConfiguration类可能是开始调查的好地方。

The second solution is to modify Infinispan Spring integration code and add switching functionality there. 第二种解决方案是修改Infinispan Spring集成代码并在其中添加切换功能。 In order to achieve this you would have to override SpringRemoteCacheManagerFactoryBean , SpringRemoteCacheManager and SpringRemoteCache . 为了实现这一点,您将必须重写SpringRemoteCacheManagerFactoryBeanSpringRemoteCacheManagerSpringRemoteCache I would advice putting switching code in SpringRemoteCache#get. 我建议将切换代码放在SpringRemoteCache#get中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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