Skip to content

quillphp/quill-idempotency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quill Idempotency Middleware

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

About

Prevents duplicate API operations by caching successful responses based on a client-provided key

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages