Download the PHP package brightfish/caching-guzzle without Composer
On this page you can find all versions of the php package brightfish/caching-guzzle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brightfish/caching-guzzle
More information about brightfish/caching-guzzle
Files in brightfish/caching-guzzle
Package caching-guzzle
Short Description Cache HTTP responses through Guzzle middleware
License GPL-3.0-only
Homepage https://github.com/brightfish-be/caching-guzzle#readme
Informations about the package caching-guzzle
HTTP caching middleware for Guzzle
Simple and transparent HTTP response caching middleware for Guzzle, works well with Laravel or with any caching library implementing the PSR-16 caching interface.
Installation
You can install the library with Composer:
How to use
The registration of the middleware follows Guzzle's documentation:
Instantiation parameters
Next to a PSR-16 compliant cache, the middleware takes two optional parameters:
$ttl
, the default cache duration, which can be overridden by each request$log
, instructs the package to log cache hits Laravel's log or PHP's defaulterror_log
(see source).
Making requests
Available options:
Option | Type | Default | Description |
---|---|---|---|
cache |
bool | true |
Completely disable the cache for this request |
cache_anew |
bool | false |
Bypass the cache and replace it with the new response |
cache_ttl |
int | 60 |
Cache duration in seconds, use -1 to cache forever |
cache_key |
string | true |
Cache key to override the default one based on the request URI (see Cache retrieval) |
Example: cache the response for 90s (default: 60)
Example: request anew and update the cache
Example: disable caching
Example: cache forever with a custom key
If cache_ttl
is set to 0
the response will not be cached, but, contrary to 'cache' => false
, it may be retrieved from it.
Example: cache retrieval
Using the wrapper
Instead of manually configuring Guzzle's client and the caching middleware, it is also possible to instantiate the Client
class provided by this package. This way, the binding of the middleware is done for you.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- dotburo
- Peter Forret
- All Contributors
License
GNU General Public License (GPL). Please see the license file for more information.