top | item 38509126

(no title)

vlakreeh | 2 years ago

I highly recommend anyone using this to use a Durable Object https://developers.cloudflare.com/durable-objects/ for writes as this project doesn't seem to have consistency guarantees. If the Worker that writes to a collection happens to both do a write at the same time the data will be whatever the last Worker to write set it to.

Very cool library for read-centric use cases but I'd be very careful using this for use cases with frequent writes.

discuss

order

baby|2 years ago

I tried using durable objects and the API is sooooo confusing I ended up just moving to a firebase’s firestore.

I know they provide different features but I just needed a nosql type of storage so I didn’t care.

wombarly|2 years ago

Couldn't the library implement a conditional operation using the etag, retrying if it fails? That should solve the consistency guarantee.

Ofc its a different matter if you write to the same key in the same file. But that could be solved with special method that allows you to do a setOrUpdate on a key in the json and when retrying the update method is executed again (allowing you to do increments or add a new item to an array) while guaranteeing consistency.

danielheath|2 years ago

Consider the case of two workers both trying to write the same key at once. Which one should succeed?