javascript - How to implement Optimistic Locking in an Azure Mobile Service? -


i have azure mobile service backend app. use mssql in out-of-the-box manner. however, have multiple clients can access same objects @ same time in theory. adequate solution me use optimistic locking avoid further concurrency problems.

so question this. have timestamp that's filled in backend. question whether there's neat way handle fetching "old version" of item in process or forced manually query object database - or whether it's possible incorporate date constraint in query similar to

function update(item, user, request) {     query.where...     request.execute(); } 

but there no query in update? performance important app expect there lot of queries.

optimistic locking doesn't make sense web. read , update operations stateless , part of independent requests (brushing on http might idea).

that's not each request can't use transaction (see mssql object http://msdn.microsoft.com/en-us/library/windowsazure/jj554212.aspx). fundamentally distributed web application, introducing transaction across multiple requests bad architectural decision. (see cap theorem).

you simulate transactions or "sagas" using azure queues , messages commands , events change new state in database manage locking records user. or have table manage record locks existing table. either way, have make record locking explicit in application logic because read , update different requests , inherent nature of stateless web , distributed computing.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -