Reputation: 1529
I'm working with a app that has both online datastore(GAE) and an offline datastore(HTML5 websql). So to resolve synchronizing problems, i'm trying to implement a locking mechanism. It should work like a semaphore, or as master-slave mechanism. User can get the lock, and if not available, can request for it. (although starvation is possible, it is handled by an user-policy)
So is there any facilities provided in App Engine to implementing this locking mechanism.
thanks in advance...
Upvotes: 1
Views: 553
Reputation: 80330
There is no explicit mechanism for locking in GAE Datastore.
However, Datastore supports transactions, so you could create (for example) a SyncLock
entity and set a property locked
to true
inside a transaction.
Note that creating a SyncLock
is not covered by transaction, but updating an existing one is. So different sessions should try to access the same SyncLock
entity and this can only be achieved if entities have the same ID. So you should use userID as ID for SyncLock
.
Upvotes: 2