TJwoods
TJwoods

Reputation: 65

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.

The questtion is about 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.

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.

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 ?

I try use invalidation mode with opening CLusterLoader but there is a risk of getting old value when node get data from other nodes.

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.

Which performance will be better for invalidation and synchronous replication ?

Looking forward to your help. Thanks

Upvotes: 2

Views: 319

Answers (1)

karesti
karesti

Reputation: 338

Spring annotations won't fully support INVALIDATION mode unless you use a ClusterLoader. 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. Annotations work well with LOCAL, REPL and DIST modes.

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.

Upvotes: 3

Related Questions