Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

gigamap lock for non-existing key

Can I lock non-existing key? I need to create only 1 (singleton) object in distributed space and share this instance between apps. And for ex. I have 2 applications which are trying to get/put this object. The expected behavior is:

start transaction
    if(map.get(MyObjectType.class) == null) {
        map.putAndUnlock(MyObjectType.class, new MyObjectType())
    } else {
        // init MyObjectType instance with getted value from map 
commit transaction

But this code doesn't work. I found out this code in TransactionManager class:

// TODO GS-9310: design and implement a solution for locking non-existent keys.
map.put(key, EMPTY_LOCK_VALUE, tr, Integer.MAX_VALUE);

So, question is can I implement my behavior using GS 10.1.1-12280 version?

asked 2017-02-12 12:20:40 -0500

nik515 gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

I've tried this and it seems to work for me. What errors are you getting?

answered 2017-05-08 11:14:46 -0500

Dixson Huie gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2017-02-12 12:20:40 -0500

Seen: 113 times

Last updated: May 08 '17