3 namespace seekat\API\Call\Cache\Service
;
5 use http\Client\Response
;
6 use Psr\Cache\CacheItemInterface
;
7 use Psr\Cache\CacheItemPoolInterface
;
8 use seekat\API\Call\Cache\Service
;
10 final class ItemPool
implements Service
{
12 * @var CacheItemPoolInterface
17 * @var CacheItemInterface
21 public function __construct(CacheItemPoolInterface
$cache) {
22 $this->cache
= $cache;
27 * @param Response|null $response
29 * @throws \Psr\Cache\InvalidArgumentException
31 public function fetch(string $key, Response
&$response = null) : bool {
32 $this->item
= $this->cache
->getItem($key);
33 if ($this->item
->isHit()) {
34 $response = $this->item
->get();
40 public function store(string $key, Response
$response) : bool {
41 $this->item
->set($response);
42 return $this->cache
->save($this->item
);
47 * @throws \Psr\Cache\InvalidArgumentException
49 public function del(string $key) {
50 $this->cache
->deleteItem($key);
53 public function clear() {
54 $this->cache
->clear();