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 rate limiting (`429`) errors to be thrown.
142
+
143
+
You should not write more than once per second to the same key. Consider consolidating your writes to a key within a Worker invocation to a single write, or wait at least 1 second between writes.
144
+
145
+
The following example serves 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.
146
+
147
+
```typescript
148
+
exportdefault {
149
+
asyncfetch(request, env, ctx):Promise<Response> {
150
+
// Rest of code omitted
151
+
constkey="common-key";
152
+
constparallelWritesCount=20;
153
+
154
+
// 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