Cache extension for PSR-18 HTTP client.
Install this package and your favorite psr-18 implementation, psr-17 implementation and psr-6 implementation.
composer require webclient/ext-cache:^1.0
<?php
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\SimpleCache\CacheInterface;
use Webclient\Extension\Cache\Client;
/**
* @var ClientInterface $client Your PSR-18 HTTP Client
* @var CacheInterface $cache Your PSR-6 Simple cache
* @var ResponseFactoryInterface $responseFactory Your PSR-17 response factory
* @var StreamFactoryInterface $streamFactory Your PSR-17 stream factory
*/
$http = new Client($client, $cache, $responseFactory, $streamFactory, 'unique-string-for-private-caching');
/** @var RequestInterface $request */
$response = $http->sendRequest($request);