https://github.com/peroks/guzzle-file-cache
A lightweight file cache for Guzzle 7+ implementing the PSR-6 Caching Interface
https://github.com/peroks/guzzle-file-cache
api-client cache caching file-cache guzzle guzzle-handler lightweight php psr-16
Last synced: 5 months ago
JSON representation
A lightweight file cache for Guzzle 7+ implementing the PSR-6 Caching Interface
- Host: GitHub
- URL: https://github.com/peroks/guzzle-file-cache
- Owner: peroks
- License: mit
- Created: 2022-05-26T15:32:09.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-13T00:00:57.000Z (over 1 year ago)
- Last Synced: 2025-07-26T05:48:47.056Z (11 months ago)
- Topics: api-client, cache, caching, file-cache, guzzle, guzzle-handler, lightweight, php, psr-16
- Language: PHP
- Homepage:
- Size: 36.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple file caching for the Guzzle http client
### A lightweight file cache for Guzzle 7+ implementing the PSR-16 Caching Interface
## How to use
push( $cache );
$options['handler'] = $stack;
return new Client( $options );
}
You use an instance of the `Peroks\GuzzleFileCache\Cache` class to add
file-caching as a handler (middleware) to the Guzzle http client.
`Peroks\GuzzleFileCache\FileStorage` does the real work, implementing the
[PSR-16: Common Interface for Caching Libraries](https://www.php-fig.org/psr/psr-16/).
After you have added caching to the Guzzle http client, there is a new
option for caching: `ttl` (time-to-live). The `ttl` value is in seconds.
You can set this option for each request sent through the client.
If you omit this option or set `ttl` to `0`, the request is not cached.
$response = $client->send( $request, [ 'ttl' => 3600 ] ); // 1 hour caching.
## Installing
You need **composer** to download and install peroks/guzzle-file-cache.
Just run `composer require peroks/guzzle-file-cache` in your project.