Reputation: 31
What's the best way to atomically modify an object in GG?
GridCache<String, Message> cache = GridGain.grid().cache("message");
Message message = cache.get(messageId);
if(message != null) {
message.setReadDate(new Date());
cache.putxAsync(messageId, message);
}
I'm hoping to replace it with atomic operation that is executed on the data node
cache.execute(messageId, new Task() {
public void execute(V value) {
value.setReadDate();
return value;
}
});
Upvotes: 0
Views: 54
Reputation: 2292
GridGain has cache.transform(...)
and cache.transformAndCompute(...)
methods which work exactly like you need.
Please take a look at Delta (a.k.a. Partial) Updates section in documentation.
Upvotes: 1