I'd like to know if there is a way to do atomic update to the cache entry conditionally, ie. for example something like this:
cache.putCondtitionally(key, newEntity, (oldEntity, newEntity) -> oldEntity.timestamp().isBefore(newEntity.timestamp()))
My concrete use-case is, that I receive updates to the entities which can be out of order, and I do not want to overwrite the entity already in the cache with "older" one. I'm OK if I miss some updates.
I'd like to manage this on cache in ATOMIC mode (no locks, no transactions).
Thx.
If you have a copy of the old object, you can use IgniteCache#replace(key, oldValue, newValue)
.
For something more complex you can use an entry processor, which uses the IgniteCache#invoke()
method.