cache)) { return; } $key = $this->getFullCacheKey($k); if (is_null($key)) { return; } $cacheItem = $this->cache->getItem($key); if ($cacheItem->isHit()) { return $cacheItem->get(); } } /** * Saves the value in the cache when that is available. */ private function setCachedValue($k, $v) { if (is_null($this->cache)) { return; } $key = $this->getFullCacheKey($k); if (is_null($key)) { return; } $cacheItem = $this->cache->getItem($key); $cacheItem->set($v); $cacheItem->expiresAfter($this->cacheConfig['lifetime']); return $this->cache->save($cacheItem); } private function getFullCacheKey($key) { if (is_null($key)) { return; } $key = $this->cacheConfig['prefix'] . $key; // ensure we do not have illegal characters $key = preg_replace('|[^a-zA-Z0-9_\.!]|', '', $key); // Hash keys if they exceed $maxKeyLength (defaults to 64) if ($this->maxKeyLength && strlen($key) > $this->maxKeyLength) { $key = substr(hash('sha256', $key), 0, $this->maxKeyLength); } return $key; } }