for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace kalanis\kw_cache\Cache;
use kalanis\kw_cache\CacheException;
use kalanis\kw_cache\Interfaces;
/**
* Class Formatted
* @package kalanis\kw_cache\Cache
* Caching content in any cache - another cache as semaphore for detection
*/
class Formatted
{
protected Interfaces\ICache $cache;
protected Interfaces\IFormat $format;
public function __construct(Interfaces\ICache $cache, Interfaces\IFormat $format)
$this->cache = $cache;
$this->format = $format;
}
* @param string[] $what
* @throws CacheException
public function init(array $what): void
$this->cache->init($what);
* @return bool
public function exists(): bool
return $this->cache->exists();
* @param mixed $content
public function set($content): bool
return $this->cache->set(strval($this->format->pack($content)));
* @return mixed
public function get()
return $this->exists() ? $this->format->unpack($this->cache->get()) : null;
public function clear(): void
$this->cache->clear();