IMO the design of the Storage API makes it difficult to properly handle concurrent updates. Storage is a relatively simple asynchronous key-value store; it wasn't designed to be
ACID compliant. In particular, the Storage API doesn't support
transactions, so you may run into race conditions in any situation where you have multiple parts of your application that attempt to update the database simultaneously and end up clobbering each other's changes.
wOxxOm's suggestion is solid if all of your application state and database interactions can take place in a single JS environment, but if you need to perform updates in multiple JS environments (e.g. multiple pages) the limitations of the Storage API come right back.
IndexedDB has an advantage here because it can batch multiple operations together into a single transaction. This in turn allows you to write your database update in a way that will allow you to detect that something went wrong and to retry as appropriate. For example:
- Read the current value stored in a given key
- Check whether that value has been modified from its expected value
- If it has been modified, abort the transaction (and tell the caller why)
- If not, proceed
- Write the updated value to the specified key
While it's possible for an extension developer to implement a transaction system using the Storage API, doing so would take a decent amount of work and would have an impact on the extension's architecture.