emanueleminotto/guzzle-cache-subscriber

Server side caching for Guzzle 4/5

1.0.0 2015-02-27 00:05 UTC

This package is auto-updated.

Last update: 2021-08-28 00:09:15 UTC


README

Build Status SensioLabs Insight Coverage Status Scrutinizer Code Quality Total Downloads

Server side caching (based on doctrine/cache) for Guzzle 4/5.

Server side caching helps to improve performances intercepting cached requests before these are sent to the URL (save network usage), and caching (when possible and permitted) responses.

API: emanueleminotto.github.io/guzzle-cache-subscriber

Install

Install the CacheSubscriber adding emanueleminotto/guzzle-cache-subscriber to your composer.json or from CLI:

$ composer require emanueleminotto/guzzle-cache-subscriber

Usage

use GuzzleHttp\Client;
use EmanueleMinotto\Guzzle\CacheSubscriber;

$client = new Client();

$subscriber = new CacheSubscriber(/* Doctrine cache instance, optional */);
// there are the getCache and setCache methods to
// change the storage system

$client->getEmitter()->attach($subscriber);

// request sent
$client->get('http://httpbin.org');

// request intercepted
$client->get('http://httpbin.org');