2021-06-11 11:03:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare (strict_types=1);
|
|
|
|
namespace Rector\Caching;
|
|
|
|
|
2021-08-02 19:35:36 +00:00
|
|
|
use Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface;
|
2021-06-11 11:03:31 +00:00
|
|
|
final class Cache
|
|
|
|
{
|
|
|
|
/**
|
2021-08-02 19:35:36 +00:00
|
|
|
* @var \Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface
|
2021-06-11 11:03:31 +00:00
|
|
|
*/
|
2021-07-28 07:05:44 +00:00
|
|
|
private $cacheStorage;
|
2021-08-02 19:35:36 +00:00
|
|
|
public function __construct(\Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface $cacheStorage)
|
2021-06-11 11:03:31 +00:00
|
|
|
{
|
2021-07-28 07:05:44 +00:00
|
|
|
$this->cacheStorage = $cacheStorage;
|
2021-06-11 11:03:31 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return mixed|null
|
|
|
|
*/
|
|
|
|
public function load(string $key, string $variableKey)
|
|
|
|
{
|
2021-07-28 07:05:44 +00:00
|
|
|
return $this->cacheStorage->load($key, $variableKey);
|
2021-06-11 11:03:31 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param mixed $data
|
|
|
|
*/
|
|
|
|
public function save(string $key, string $variableKey, $data) : void
|
|
|
|
{
|
2021-07-28 07:05:44 +00:00
|
|
|
$this->cacheStorage->save($key, $variableKey, $data);
|
2021-06-11 11:03:31 +00:00
|
|
|
}
|
|
|
|
public function clear() : void
|
|
|
|
{
|
2021-07-28 07:05:44 +00:00
|
|
|
$this->cacheStorage->clear();
|
2021-06-11 11:03:31 +00:00
|
|
|
}
|
|
|
|
public function clean(string $cacheKey) : void
|
|
|
|
{
|
2021-07-28 07:05:44 +00:00
|
|
|
$this->cacheStorage->clean($cacheKey);
|
2021-06-11 11:03:31 +00:00
|
|
|
}
|
|
|
|
}
|