Pergunta

Clustered invalidation key-value caches are sending only remove commands over the network. When the value of a key is changed or removed on one node a remove command is sent with that key to every other node so they need to get that data from a persistent store (or re-calculate it) next time they need it.

My question is: How it is defined based on the javax.cache.Cache interface? There is put, putIfAbsent, replace, ... functions there.

Using Infinispan-jcache I could not have a behaviour when the same key exists on two different node. I asked the same question on their user forum at https://community.jboss.org/thread/228039 however I think this is a more common question where all JSR-107 implementations are affected.

I checked the draft specification but I could not find anything about Clustering and invalidation there.

Foi útil?

Solução

The way Infinispan is working is correct. Invalidation means that when a node receives a put/replace/putIfAbsent/remove calls, it will send a message to the other nodes to remove the entry. So, when the entry is stored in cache2, it's removed from cache1. It doesn't verify if the value is the same or not.

JSR-107 does not specify how caches should behave in a cluster. JSR-107 only focuses on local caches. The behaviour of Infinispan caches, even under JCache API, for invalidated, distributed and replicated caches is specific to Infinispan.

Outras dicas

The JCache standard is final now. See: https://jcp.org/en/jsr/detail?id=107

You can find the code at: https://github.com/jsr107

If you need an implementation of JCache, the only one that I'm aware of being available today is Oracle Coherence; see: http://docs.oracle.com/middleware/1213/coherence/develop-applications/jcache_part.htm

For the sake of full disclosure, I work at Oracle. The opinions and views expressed in this post are my own, and do not necessarily reflect the opinions or views of my employer.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top