Idempotency middleware for the Quill PHP Framework. Prevents duplicate API operations by caching successful responses based on a client-provided key.
composer require quillphp/idempotencyuse Quill\Idempotency\Idempotency;
use Quill\Storage\RedisStorage;
$app->use(Idempotency::new([
'storage' => new RedisStorage(['host' => '127.0.0.1']),
'header' => 'X-Idempotency-Key',
'ttl' => 86400, // 24 hours
]));| Option | Default | Description |
|---|---|---|
| `storage` | `null` | Required. Any `StorageInterface` instance (Redis, APCu, etc.). |
| `header` | `'X-Idempotency-Key'` | The HTTP header containing the idempotency key. |
| `ttl` | `86400` | How long to cache response (in seconds). |
| `methods` | `['POST', 'PATCH', 'PUT']` | HTTP methods to enforce idempotency on. |
| `cached_header` | `'X-Idempotency-Cached'` | The header added to cached responses. |
MIT