Support increment/decrement operations (atomic counters) in Workers KV

Currently, Workers KV only supports read/write and list operations.

I’m considering my options with regards to building an API, and an increment/decrement operation in this feature would be nice for rate limiting API keys to a certain number of requests per day (or another time frame).

Workers KV is currently a distributed, last-write-wins store. For the aforementioned use case, it means if a key containing the daily usage value hasn’t been propagated to a given edge location, the worker may read the older value and write it, and thereby causing the correct value (which hasn’t been propagated yet) to be discarded for the older value.

Increment/decrement operations would allow for discrepancies to be reconciled between various edge locations as they are very specific manipulations where the order does not matter.

Not so many votes, though. The feature is required for any kind of statistics, so I wonder, are there no applications that need it? Shouldn’t be too complicated to implement, since Cloudflare themselves do count workers events…

I’d love to see this feature too. :grinning:


I would love to have such a feature. Right now because the KV store is eventually consistent it’s hard to know if all my views are being counted correctly.

1 Like

need this feature too

1 Like

If I could, I’d give all my votes to this.

:heavy_plus_sign: :heavy_plus_sign: :heavy_plus_sign: :heavy_plus_sign: :heavy_plus_sign: :heavy_plus_sign: :heavy_plus_sign: