Re:Lowstorage: JSON-based database for Cloudflare Workers an...
by wombarly on Sunday December 03, 2023 @03:34PM
(#38510494)
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.
Re:Lowstorage: JSON-based database for Cloudflare Workers an...
by danielheath on Sunday December 03, 2023 @03:46PM
(#38510600)
Consider the case of two workers both trying to write the same key at once. Which one should succeed?
Re:Lowstorage: JSON-based database for Cloudflare Workers an...
by neon_me on Sunday December 03, 2023 @04:13PM
(#38510828)
Its up to your implementation. Which is very similar to any other "average" database ...
Re:Lowstorage: JSON-based database for Cloudflare Workers an...
by wombarly on Sunday December 03, 2023 @04:30PM
(#38510956)
If you use etags it's up to R2. I'm assuming R2 is consistent here.
So if you write to the same file twice, one write will succeed before the other and change the etag of the file, which should in theory cause the other request to R2 to fail because the etag you send with as conditional no longer matches.
Re:Lowstorage: JSON-based database for Cloudflare Workers an...
by baby on Sunday December 03, 2023 @01:43PM
(#38509568)
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.
Very cool library for read-centric use cases but I'd be very careful using this for use cases with frequent writes.