Hi Prashant,

thanks.

On Jun 16, 4:01 pm, Prashant <[email protected]> wrote:
> I can think of two approaches:
>
> 1. Let all threads read the data (in parallel) and use transaction to update
> the data. Transaction will fail for all the thread except for one. Threads
> with failed transaction will again read data, recompute the things and try
> to update the data again.

Well, sounds as a reasonable solution. Nevertheless if the suggestion
of Ernesto works, looks cleaner for me...

>
> 2. Implement a global locking scheme - Make a dummy entity with a field of
> type boolean. Take true == "lock acquired" & false == "lock free". A thread
> which is trying to update the data will have to acquire the lock before
> reading data. To acquire a lock a thread will try to set lock = true, using
> transaction. If lock is already taken, thread will wait for the locking
> thread to release the lock.
>
> In the second case, number of datastore reads can be reduced by caching lock
> entity in memcache.

I tried it with global lock in memcache, but there's no atomic test
and set function, so it does not work, or am I missing things out?

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to