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

Ask Your Question
0

How to update the obj while reading from the cache?

I have two web services calls: 1. reserve the port 2. retrieve the reserved port

Reserve the port logic will work as below: 1. read the AVAILABLE (status) port object from the pool (in memory data grid) 2. update the port object status as IN_USE 3. return the port as a response

Retrieve the reserved port logic will work as below: 1. IN_USE port will be returned.

Problem in First web service call: 1. while two / more threads are running (simultaneously) to make the port as reserved. 2. Both threads are reserving the same port from the pool.

How to update the obj while reading from the cache? I have to update the cache once the obj is read from the cache. Then this problem will be solved. Or is there any other way to solve this?

I have attached the code snippets.

Edited by: Gopinathan Mani on May 2, 2013 7:12 AM

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=4069]{quote}

asked 2013-04-30 08:51:26 -0600

get4gopim gravatar image

updated 2013-08-08 09:52:00 -0600

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

You have 2 options : pessimistic locking or optimistic locking.
If you update only few fields you should consider to use the change API.
See:
http://wiki.gigaspaces.com/wiki/display/XAP95/PessimisticLocking
http://wiki.gigaspaces.com/wiki/display/XAP95/OptimisticLocking
http://wiki.gigaspaces.com/wiki/display/XAP95/ChangeAPI

Shay

answered 2013-05-01 23:43:46 -0600

shay hassidim gravatar image
edit flag offensive delete link more

Comments

Hi Shay,

Thanks for your valuable inputs.

Both optimistic and pessimistic locking worked for this solution.

Change API is not worked.

get4gopim gravatar imageget4gopim ( 2013-05-03 00:32:04 -0600 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-04-30 08:51:26 -0600

Seen: 25 times

Last updated: May 01 '13