Skip to content

Commit b5c5b67

Browse files
committed
Adds more info and a diagram to improve idempotencyKeyTTLs
1 parent c029b38 commit b5c5b67

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

docs/idempotency.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ await tasks.batchTrigger("my-task", [
9494

9595
## `idempotencyKeyTTL` option
9696

97+
The `idempotencyKeyTTL` option defines a time window during which a task with the same idempotency key will only run once. Here's how it works:
98+
99+
1. When you trigger a task with an idempotency key and set `idempotencyKeyTTL: "5m"`, it creates a 5-minute window.
100+
2. During this window, any subsequent triggers with the same idempotency key will return the original task run instead of creating a new one.
101+
3. Once the TTL window expires, the next trigger with that idempotency key will create a new task run and start a new time window.
102+
103+
![idempotency-key-ttl](/images/idempotency-key-ttl.png)
104+
97105
By default idempotency keys are stored for 30 days. You can change this by passing the `idempotencyKeyTTL` option when triggering a task:
98106

99107
```ts

docs/images/idempotency-key-ttl.png

38.1 KB
Loading

0 commit comments

Comments
 (0)