Workers and KV Store commit checks

The KV store seems like it would be handy for storing lightweight aggregate state.

I’ve looked through a number of posts on the KV store and, from what i gather, write requests are sent to a central store and read requests pull from the store, with caching to help performance. It seems to be Last Write Wins, with no message order guarantee.

It would also be nice if some form of commit semantics were possible to ensure that the aggregates can use the store to maintain their (lightweight) state.

Incrementing a metric, regardless of the current value of the metric, would also be nice. This might be done via the equivalent of a server-side script. If sandboxed per-request scripting was exposed to the Worker, it might open up other possibilities.

Redis offers server-side scripting and Multi/Watch… perhaps something similar might be supported by the KV store if it isn’t already.

Does it seem possible that the KV store will support something like this at some point?

Worker/message queues or something like Lambda Tasks has been requested a few times, even more than a year back. So Cloudflare already know there’s demand for it, but no dates are promised here. If it arrives it arrives.

Meanwhile, if you need ACID transactions, I’d suggest looking at FaunaDB.
There’s a native driver that will work on Cloudflare Workers as well.

Also checkout Ably, a tutorial can be found here.

Even more here: Realtime support for Workers KV (onChange)

1 Like

ok… it just seems like it might be low-hanging fruit.