GemberPHP /
cache-psr
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Gember\CachePsr; |
||
| 6 | |||
| 7 | use DateInterval; |
||
| 8 | use Gember\EventSourcing\Util\Cache\Cache; |
||
| 9 | use Psr\SimpleCache\CacheInterface; |
||
| 10 | use Override; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @template T of mixed |
||
| 14 | * |
||
| 15 | * @implements Cache<T> |
||
| 16 | */ |
||
| 17 | final readonly class PsrSimpleCache implements Cache |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 18 | { |
||
| 19 | 2 | public function __construct( |
|
| 20 | private CacheInterface $psrSimpleCache, |
||
| 21 | 2 | ) {} |
|
| 22 | |||
| 23 | 2 | #[Override] |
|
| 24 | public function get(string $key): mixed |
||
| 25 | { |
||
| 26 | 2 | return $this->psrSimpleCache->get($key); |
|
| 27 | } |
||
| 28 | |||
| 29 | 2 | #[Override] |
|
| 30 | public function has(string $key): bool |
||
| 31 | { |
||
| 32 | 2 | return $this->psrSimpleCache->has($key); |
|
| 33 | } |
||
| 34 | |||
| 35 | 2 | #[Override] |
|
| 36 | public function set(string $key, mixed $data, ?DateInterval $timeToLive = null): void |
||
| 37 | { |
||
| 38 | 2 | $this->psrSimpleCache->set($key, $data, $timeToLive); |
|
| 39 | } |
||
| 40 | } |
||
| 41 |