File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,12 @@ $client->connect('127.0.0.1', 6379);
77
77
$pool = new RedisCachePool($client);
78
78
79
79
$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();
81
86
```
82
87
83
88
Using cache, the client will get cached responses if resources haven't changed since last time,
Original file line number Diff line number Diff line change @@ -374,14 +374,23 @@ public function addHeaders(array $headers)
374
374
}
375
375
376
376
/**
377
+ * Add a cache plugin to cache responses locally.
377
378
* @param CacheItemPoolInterface $cache
378
379
*/
379
- public function useCache (CacheItemPoolInterface $ cachePool )
380
+ public function addCache (CacheItemPoolInterface $ cachePool )
380
381
{
381
382
$ this ->removePlugin (Plugin \CachePlugin::class);
382
383
$ this ->addPlugin (new Plugin \CachePlugin ($ cachePool ));
383
384
}
384
385
386
+ /**
387
+ * Remove the cache plugin
388
+ */
389
+ public function removeCache ()
390
+ {
391
+ $ this ->removePlugin (Plugin \CachePlugin::class);
392
+ }
393
+
385
394
/**
386
395
* @param string $name
387
396
*
You can’t perform that action at this time.
0 commit comments