4358f1f2f17f37233a6df9a612aa206e1f728227
[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 * @var CacheInterface
12 */
13 private $cache;
14
15 public function __construct(CacheInterface $cache) {
16 $this->cache = $cache;
17 }
18
19 public function fetch(string $key, Response &$response = null) : bool {
20 $response = $this->cache->get($key);
21 return !!$response;
22 }
23
24 public function store(string $key, Response $response) : bool {
25 return $this->cache->set($key, $response);
26 }
27
28 public function del(string $key) {
29 $this->cache->delete($key);
30 }
31
32 public function clear() {
33 $this->cache->clear();
34 }
35 }