On Tue, Sep 8, 2009 at 5:41 PM, Robert O'Callahan <rob...@ocallahan.org>wrote:
> On Tue, Sep 8, 2009 at 7:00 PM, Aaron Boodman <a...@google.com> wrote: > >> On Fri, Sep 4, 2009 at 12:02 AM, Chris Jones<cjo...@mozilla.com> wrote: >> > I propose adding the functions >> > >> > window.localStorage.beginTransaction() >> > window.localStorage.commitTransaction() >> > or >> > window.beginTransaction() >> > window.commitTransaction() >> >> I think this is a good idea! I would modify it to follow the pattern >> set by the current SQLDatabase proposal, to have a callback, like >> this: >> >> window.localStorage.transaction(function() { >> // use local storage here >> }); >> >> > What is the intended semantics here? Chris' explicit commitTransaction > would throw an exception if the transaction was aborted due to data > inconsistency, leaving it up to the script to retry --- and making it clear > to script authors that non-storage side effects during the transaction are > not undone. How would you handle transaction aborts? > You'd have to implement it via a mutex. An optimized implementation could wait until the first operation that can't be un-done before acquiring it, and do everything optimistically until then. This is the same situation as WebDatabase if I understand it correctly.