简体   繁体   English

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

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

I have a springboot project used infinispan to run the invalidation mode under the cluster for cache.我有一个springboot项目使用infinispan在集群下运行失效模式进行缓存。

The questtion is about infinispan.问题是关于infinispan。 In fact, I read the official document: "In invalidation, the caches on different nodes do not actually share any data" and now I am in this situation.事实上,我阅读了官方文档: "In invalidation, the caches on different nodes do not actually share any data" ,现在我处于这种情况。

I use the method a provided: Cache.putForExternalRead(key, value) and this method can solve the problem that when I puts the data into the cache of the Node A, the B node invalidates it, But I can't use the springboot annotations, such as @Cacheable.我使用了a提供的方法: Cache.putForExternalRead(key, value) ,这个方法可以解决当我把数据放入Node A的缓存时,B节点失效,但是springboot不能使用的问题注释,例如@Cacheable。

I also read "Invalidation mode can be used with a shared cache store."我还阅读了“失效模式可以与共享缓存存储一起使用”。 from document but I don't know how to do this and I hope you can provide some help.从文档,但我不知道如何做到这一点,我希望你能提供一些帮助。

The goal I hope to achieve is that in the invalidation mode, I put a data into the cache of Node A, Node B will accept a copy data from A.Can I do this with invalidation mode ?我希望实现的目标是在失效模式下,我将数据放入节点 A 的缓存中,节点 B 将接受来自 A 的副本数据。我可以在失效模式下执行此操作吗?

I try use invalidation mode with opening CLusterLoader but there is a risk of getting old value when node get data from other nodes.我尝试在打开CLusterLoader使用失效模式,但是当节点从其他节点获取数据时,存在获取旧值的风险。

I use replicated mode now.我现在使用复制模式。 However, "replication practically only performs well in small clusters(under 10 nodes)" and "Asynchronous replication is not recommended" .So I just can use synchronous replication.然而, "replication practically only performs well in small clusters(under 10 nodes)""Asynchronous replication is not recommended" 。所以我只能使用同步复制。

Which performance will be better for invalidation and synchronous replication ?失效和同步复制哪个性能更好?

Looking forward to your help.期待您的帮助。 Thanks谢谢

Spring annotations won't fully support INVALIDATION mode unless you use a ClusterLoader.除非您使用 ClusterLoader,否则 Spring 注释不会完全支持 INVALIDATION 模式。 Under the hood annotations use put , we might consider adding a feature to support putForExternalRead behavior in the future, but it won't be there very soon.putForExternalRead注释使用put ,我们可能会考虑在未来添加一个功能来支持putForExternalRead行为,但它不会很快出现。 Annotations work well with LOCAL, REPL and DIST modes.注释适用于 LOCAL、REPL 和 DIST 模式。

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

If you are afraid about getting stale values and not being performant enough with a replicated cache, you might consider using a distributed cache.如果您害怕获得过时的值并且担心复制缓存的性能不够,您可以考虑使用分布式缓存。

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

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