0

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;
        }
    });

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.