You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Workers KV has a maximum of 1 write to the same key per second. Writes made to the same key within 1 second will cause errors to be thrown.
142
+
143
+
The following example serves only as a demonstration of how multiple writes to the same key may return errors by forcing concurrent writes within a single Worker invocation. This is not a pattern that should be used in production.
144
+
145
+
```typescript
146
+
exportdefault {
147
+
asyncfetch(request, env, ctx):Promise<Response> {
148
+
// Rest of code omitted
149
+
constkey="common-key";
150
+
constparallelWritesCount=20;
151
+
152
+
// Helper function to attempt a write to KV and handle errors
You can also [write key-value pairs from the command line with Wrangler](/kv/reference/kv-commands/#create) and [write data via the API](/api/operations/workers-kv-namespace-write-key-value-pair-with-metadata).
0 commit comments