springboot + infinispan失效模式:如何与共享缓存存储一起使用?

springboot + infinispan invalidation mode : How can used with shared cache storage?

我有一个springboot项目使用了infinispan来运行缓存集群下的失效模式

问题是关于无穷大的。 其实看了官方文档:"In invalidation, the caches on different nodes do not actually share any data",现在就是这种情况。

我用的是a提供的方法:Cache.putForExternalRead(key, value)这个方法可以解决我把数据放到A节点的缓存中,B节点就失效了,但是我不能用springboot注解,如@Cacheable.

我也看了文档"Invalidation mode can be used with a shared cache store.",但是我不知道怎么做,希望你能提供一些帮助。

我希望达到的目标是在失效模式下,我把一个数据放到节点A的缓存中,节点B会接受一份来自A.Can的复制数据,我用失效模式做这个?

我尝试在打开时使用失效模式 CLusterLoader 但是当节点从其他节点获取数据时存在获取旧值的风险。

我现在使用复制模式。然而,"replication practically only performs well in small clusters(under 10 nodes)""Asynchronous replication is not recommended"。所以我只能使用同步复制。

失效和同步复制哪个性能更好?

期待您的帮助。谢谢

Spring 注释将不完全支持无效模式,除非您使用 ClusterLoader。在后台注释使用 put,我们可能会考虑在将来添加一个功能来支持 putForExternalRead 行为,但不会很快出现。 注释在 LOCAL、REPL 和 DIST 模式下运行良好。

ConfigurationBuilder b = new ConfigurationBuilder();
b.persistence()
    .addClusterLoader()
    .remoteCallTimeout(500);

如果您害怕获得过时的值并且担心复制缓存的性能不够好,您可以考虑使用分布式缓存。