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…
There is no explicit mechanism for locking in GAE Datastore.
However, Datastore supports transactions, so you could create (for example) a
SyncLockentity and set a propertylockedtotrueinside a transaction.Note that creating a
SyncLockis not covered by transaction, but updating an existing one is. So different sessions should try to access the sameSyncLockentity and this can only be achieved if entities have the same ID. So you should use userID as ID forSyncLock.