quillphp / idempotency
Idempotency middleware for the Quill PHP framework
dev-main
2026-04-06 10:02 UTC
Requires
- php: ^8.3
- quillphp/quill: ^0.0.2
Requires (Dev)
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2026-04-06 11:57:28 UTC
README
Idempotency middleware for the Quill PHP Framework. Prevents duplicate API operations by caching successful responses based on a client-provided key.
Installation
composer require quillphp/idempotency
Usage
use 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 ]));
Configuration
| 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. |
License
MIT