Skip to content

Commit 035e6de

Browse files
committed
Added a way to opt-out of the cache
1 parent 24e4b08 commit 035e6de

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ $client->connect('127.0.0.1', 6379);
7777
$pool = new RedisCachePool($client);
7878

7979
$client = new \Github\Client();
80-
$client->useCache($pool);
80+
$client->addCache($pool);
81+
82+
// Do some request
83+
84+
// Stop using cache
85+
$client->removeCache();
8186
```
8287

8388
Using cache, the client will get cached responses if resources haven't changed since last time,

lib/Github/Client.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,23 @@ public function addHeaders(array $headers)
374374
}
375375

376376
/**
377+
* Add a cache plugin to cache responses locally.
377378
* @param CacheItemPoolInterface $cache
378379
*/
379-
public function useCache(CacheItemPoolInterface $cachePool)
380+
public function addCache(CacheItemPoolInterface $cachePool)
380381
{
381382
$this->removePlugin(Plugin\CachePlugin::class);
382383
$this->addPlugin(new Plugin\CachePlugin($cachePool));
383384
}
384385

386+
/**
387+
* Remove the cache plugin
388+
*/
389+
public function removeCache()
390+
{
391+
$this->removePlugin(Plugin\CachePlugin::class);
392+
}
393+
385394
/**
386395
* @param string $name
387396
*

0 commit comments

Comments
 (0)