1. Go to this page and download the library: Download brightfish/caching-guzzle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
brightfish / caching-guzzle example snippets
/** @var \Psr\SimpleCache\CacheInterface $cache */
$cache = app('cache')->store('database'); // Laravel example, but any PSR-16 cache will do
$middleware = new \Brightfish\CachingGuzzle\Middleware($cache);
$stack = \GuzzleHttp\HandlerStack::create();
$stack->push($middleware);
$client = new \GuzzleHttp\Client([
'handler' => $stack,
'base_uri' => 'https://example.org/api/'
]);
$middleware = new \Brightfish\CachingGuzzle\Middleware($store, $ttl = 60, $log = true);
# Get response_1 from cache.
$cached_response_1 = $cache->get('//example.org/api/resource');
# Get response_4 from cache.
$cached_response_4 = $cache->get('my-key');
use Brightfish\CachingGuzzle\Client;
/** @var \Psr\SimpleCache\CacheInterface $store */
$psrCompatibleCache = new Cache();
$client = new Client($psrCompatibleCache, [
'cache_ttl' => 60, // default cache duration
'cache_log' => false, // log the cache hits
// Guzzle options:
'base_uri' => 'https://example.org/api/'
// ...
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.