refactor
[m6w6/seekat] / lib / API / Call / Cache / Service / Simple.php
1 <?php
2
3 namespace seekat\API\Call\Cache\Service;
4
5 use http\Client\Response;
6 use Psr\SimpleCache\CacheInterface;
7 use seekat\API\Call\Cache\Service;
8
9 final class Simple implements Service
10 {
11 /**
12 * @var CacheInterface
13 */
14 private $cache;
15
16 public function __construct(CacheInterface $cache) {
17 $this->cache = $cache;
18 }
19
20 public function fetch(string $key, Response &$response = null) : bool {
21 $response = $this->cache->get($key);
22 return !!$response;
23 }
24
25 public function store(string $key, Response $response) : bool {
26 return $this->cache->set($key, $response);
27 }
28
29 public function clear() {
30 $this->cache->clear();
31 }
32 }