webclient/ext-cache

Cache extension for PSR-18 HTTP client

v1.0.1 2020-11-04 13:18 UTC

This package is auto-updated.

Last update: 2021-05-04 14:17:48 UTC


README

Latest Stable Version Total Downloads License PHP

webclient/ext-cache

Cache extension for PSR-18 HTTP client.

Install

Install this package and your favorite psr-18 implementation, psr-17 implementation and psr-6 implementation.

composer require webclient/ext-cache:^1.0

Using

<?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);