You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by max904 <ma...@yandex.ru> on 2019/04/09 14:24:23 UTC

Cache#replace(K,V,V) implementation

1) How does Ignite implement this Cache#boolean replace(K key, V oldValue, V
newValue) function?JSR107 tells that it's equivalent to: if
(cache.containsKey(key) && *equals*(cache.get(key), oldValue)) { 
cache.put(key, newValue); return true; } else {  return false; }but I assume
this is just logical equivalence.How Ignite really perform
"equals(cache.get(key), oldValue)"? Or it uses some more intelligent way,
like comparing some hash codes or other kind of metadata. Performing
"equals" on the values could be very expensive operation.My question is very
practical. I'm implementing a Web-service that's backed by Ignite, which has
to support "Last-Modified" or "ETag" HTTP headers. These headers would make
sure the data has not been sent over the wire unnecessarily if nothing has
changed, and the data has not been concurrently updated since the last time
it was requested. These headers allow client or proxy to cache the data,
especially if the data is of a substantial size. I'm struggling to find the
most optimal way to map it to my cache operations. Therefore, here is my
second question.2) How would you recommend implementing "Last-Modified" or
"ETag" semantics based on Ignite? (more specifically in the context of
replacing/updating the values)



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Cache#replace(K,V,V) implementation

Posted by aealexsandrov <ae...@gmail.com>.
Hi,

It's true that Ignite provides the implementation for JSR107:

https://ignite.apache.org/use-cases/caching/jcache-provider.html
https://apacheignite.readme.io/docs/jcache

Unfortunately, I don't have the details of how exactly it was implemented
and can't suggest you in your questions but Apache Ignite is the open source
and you can easily get the source code:

https://github.com/apache/ignite/blob/master/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
(method replace)

Also, you can try to find the answers on developer mail list: 

http://apache-ignite-developers.2346864.n4.nabble.com

BR,
Andrei



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/