/**
* Returns a distributed cache value.
*
* This uses cache invalidation mechanism described in
*
* @see setDistributedCache() for more information invalidateCache().
*
* @param string $key
*
* @return mixed null when not found
*/
public function getDistributedCache($key)
{
$this->stopwatch->start(sprintf('Get Cache `%s`', $key));
$cache = $this->fastCache->get($key);
if (null === $cache) {
$this->stopwatch->stop(sprintf('Get Cache `%s`', $key));
return null;
}
if (!is_array($cache) || !isset($cache['timestamp'])) {
throw new \RuntimeException(sprintf('You requested a cache through the distributed cache mechanism, which was not ' . 'set through this mechanism. You can only distributed cache when you set the cache through the' . 'distributed cache. [%s]', substr($cache, 0, 50)));
}
$isValid = $this->isCacheIsValid($key, $cache['timestamp']);
$this->stopwatch->stop(sprintf('Get Cache `%s`', $key));
return $isValid ? $cache['data'] : null;
}