Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 795 Bytes

caching.md

File metadata and controls

30 lines (20 loc) · 795 Bytes

Response caching

Back to the navigation

This example uses the PSR6 cache pool redis-adapter. See http://www.php-cache.com/ for alternatives.

<?php

// This file is generated by Composer
require_once 'vendor/autoload.php';

use Cache\Adapter\Redis\RedisCachePool;

$client = new \Redis();
$client->connect('127.0.0.1', 6379);
// Create a PSR6 cache pool
$pool = new RedisCachePool($client);

$client = new \Github\Client();
$client->addCache($pool);

// Do some request

// Stop using cache
$client->removeCache();

Using cache, the client will get cached responses if resources haven't changed since last time, without reaching the X-Rate-Limit imposed by GitHub.