update to PHP-8.1
[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 public function __construct(private readonly CacheInterface $cache) {
11 }
12
13 public function fetch(string $key, Response &$response = null) : bool {
14 $response = $this->cache->get($key);
15 return !!$response;
16 }
17
18 public function store(string $key, Response $response) : bool {
19 return $this->cache->set($key, $response);
20 }
21
22 public function del(string $key) : void {
23 $this->cache->delete($key);
24 }
25
26 public function clear() : void {
27 $this->cache->clear();
28 }
29 }