Fetches contents from file cache.

@param string $sKey Cache key

@return mixed
351635
public function fromFileCache($sKey)
    {
        if (!array_key_exists($sKey, $this->_aFileCacheContents)) {
            $sRes = null;

            $aMeta = $this->getCacheMeta($sKey);
            $blInclude = isset($aMeta["include"]) ? $aMeta["include"] : false;
            $sCachePath = isset($aMeta["cachepath"]) ? $aMeta["cachepath"] : $this->getCacheFilePath($sKey);

            // trying to lock
            $this->_lockFile($sCachePath, $sKey, LOCK_SH);

            clearstatcache();
            if (is_readable($sCachePath)) {
                $sRes = $blInclude ? $this->_includeFile($sCachePath) : $this->_readFile($sCachePath);
            }

            if (isset($sRes['ttl']) && $sRes['ttl'] != 0) {
                $iTimestamp = $sRes['timestamp'];
                $iTtl = $sRes['ttl'];

                $iTime = \OxidEsales\Eshop\Core\Registry::getUtilsDate()->getTime();
                if ($iTime > $iTimestamp + $iTtl) {
                    return null;
                }
            }
            // release lock
            $this->_releaseFile($sKey, LOCK_SH);

            // caching
            $this->_aFileCacheContents[$sKey] = $sRes;
        }

        return $this->_aFileCacheContents[$sKey]['content'];
    }
959014
protected function getPayload($key)
    {
        $path = $this->path($key);

        // If the file doesn't exists, we obviously can't return the cache so we will
        // just return null. Otherwise, we'll get the contents of the file and get
        // the expiration UNIX timestamps from the start of the file's contents.
        try {
            $expire = substr(
                $contents = $this->files->get($path, true), 0, 10
            );
        } catch (Exception $e) {
            return $this->emptyPayload();
        }

        // If the current time is greater than expiration timestamps we will delete
        // the file and return null. This helps clean up the old files and keeps
        // this directory much cleaner for us as old files aren't hanging out.
        if (Carbon::now()->getTimestamp() >= $expire) {
            $this->forget($key);
            return $this->emptyPayload();
        }

        try {
            $data = decrypt(substr($contents, 10));
        } catch (DecryptException $e) {
            $this->forget($key);
            return $this->emptyPayload();
        }

        // Next, we'll extract the number of minutes that are remaining for a cache
        // so that we can properly retain the time for things like the increment
        // operation that may be performed on this cache on a later operation.
        $time = ($expire - Carbon::now()->getTimestamp()) / 60;

        return compact('data', 'time');
    }
1103445
public function remove($sKey)
    {
        if ($this->contains($sKey)) {
            $mRes = $_SESSION[$sKey];
            unset($_SESSION[$sKey]);
            return $mRes;
        } else {
            return null;
        }
    }
1313317
public function get($sKey, $sDefaultValue = null)
    {
        if (empty($sKey)) {
            return $sDefaultValue;
        }

        $obValue = Cookie::get($sKey);
        if (empty($obValue)) {
            return $sDefaultValue;
        }

        return $obValue;
    }
487392
public static function &CreateSearchCache($sKey, $sQuery, $sSearchTerm, $aSearchTerms = null, $aFilter = array())
    {
        $sShopId = null;
        $oShop = TdbShop::GetInstance();
        if ($oShop) {
            $sShopId = $oShop->id;
        }
        $oItem = self::GetSearchCacheItem($sKey, $sShopId);

        if (null === $oItem) {
            $oItem = TdbShopSearchCache::GetNewInstance();
            $aData = array('shop_id' => $oShop->id, 'searchkey' => $sKey, 'last_used_date' => date('Y-m-d H:i:s'), 'number_of_records_found' => -1);
            $oItem->LoadFromRow($aData);
            $oItem->AllowEditByAll(true);
            $oItem->Save();
            //die(0);
            $sTmpQuery = "SELECT MD5(CONCAT('".MySqlLegacySupport::getInstance()->real_escape_string($oItem->id)."-',tmpres.shop_article_id)) AS shop_search_cache_item_id,
        '".MySqlLegacySupport::getInstance()->real_escape_string($oItem->id)."' AS shop_search_cache_id, sum(tmpres.cms_search_weight) As cms_search_weight, tmpres.shop_article_id AS id from (".$sQuery.') AS tmpres group by tmpres.shop_article_id';
            if (TdbShopSearchIndexer::searchWithAND()) {
                $aTerms = TdbShopSearchIndexer::PrepareSearchWords($sSearchTerm, true);
                $sTmpQuery .= ' HAVING SUM(tmpres.wordhit) >= '.count($aTerms);
            }
            $sTmpQuery = $oItem->ProcessSearchQueryBeforeInsert($sTmpQuery);

            $query = "INSERT INTO `shop_search_cache_item` (`id`,`shop_search_cache_id`,`weight`, `shop_article_id`) {$sTmpQuery}";
            MySqlLegacySupport::getInstance()->query($query);
            $oItem->sqlData['number_of_records_found'] = MySqlLegacySupport::getInstance()->affected_rows();
            $oItem->fieldNumberOfRecordsFound = $oItem->sqlData['number_of_records_found'];
            $oItem->AllowEditByAll(true);
            $oItem->SaveFieldsFast(array('number_of_records_found' => $oItem->fieldNumberOfRecordsFound));
        } else {
            $aData = $oItem->sqlData;
            $aData['last_used_date'] = date('Y-m-d H:i:s');
            $oItem->LoadFromRow($aData);
            $oItem->AllowEditByAll(true);
            $oItem->SaveFieldsFast(array('last_used_date' => $aData['last_used_date']));
        }

        $oItem->sSearchTerm = $sSearchTerm;
        if (true === CMS_SHOP_SEARCH_ENABLE_SPELLCHECKER) {
            $oSpellCheck = &TCMSSpellcheck::GetInstance();
            $oSearchCacheObject = TdbShopSearchCache::GetNewInstance();
            $aCorrections = false;
            if (!empty($sSearchTerm)) {
                $aCorrections = $oSpellCheck->SuggestCorrection($oItem->sSearchTerm, array($oSearchCacheObject, 'GetBestSuggestion'));
            }
            if ($aCorrections) {
                $oItem->sSearchTermSpellChecked = $aCorrections['string'];
                $oItem->sSearchTermSpellCheckedFormated = $oItem->sSearchTerm;
                foreach ($aCorrections['corrections'] as $sOrg => $sCorrection) {
                    $oItem->sSearchTermSpellCheckedFormated = str_replace($sOrg, '<span class="correction">'.$sCorrection.'</span>', $oItem->sSearchTermSpellCheckedFormated);
                }
            } else {
                $oItem->sSearchTermSpellChecked = null;
                $oItem->sSearchTermSpellCheckedFormated = null;
            }
        }

        $oItem->aSearchTerms = $aSearchTerms;
        $oItem->aFilter = $aFilter;
        $oShop->SetActiveSearchCacheObject($oItem);

        return $oItem;
    }
584891
public function fetch($key) {
		$result = $this->cacheInstance->getItem ( $this->getRealKey ( $key ) )->get ();
		return eval ( $result );
	}
398760
public function fetch($key)
    {
        if(extension_loaded('apcu') && function_exists('apcu_fetch')) {
            $cached = apcu_fetch($key);
            if (!$cached) {
                return null;
            }

            return $cached;

        }else{
            return null;
        }
    }
1062912
public function get($pKey)
    {
        $file = $this->_loadFile($pKey);

        if (isset($this->_files[$file][$pKey]) and $this->_checkTtl($file, $pKey)) {
            return $this->_files[$file][$pKey][static::AGL_CACHE_VALUE];
        }

        return NULL;
    }
49606
public function read($key) {
        $cache = Zend_Registry::get('CacheFrontend');
        // fetch results from cache
        if ($cache->test($key)) {
            $results = $cache->load($key);
            if (!is_array($results)) {
                return -1;
            }
            $version = (int)$cache->load($this->_versionKey);
            // compare version numbers
            if (array_key_exists('version', $results) && (int)$results['version'] === $version) {
                return $results['data'];
            }
        }
        return -1;
    }
474090
public function getFromCache($key)
    {
        $fileName = $this->getCacheFilePath($key);
        $value = null;
        if (is_readable($fileName)) {
            $value = file_get_contents($fileName);
            if ($value == serialize(false)) {
                return false;
            }

            $value = unserialize($value);
            if ($value === false) {
                $value = null;
            }
        }

        return $value;
    }
277783
public function getCachedFile($cacheKey) {

        // Get directory and filename
        list($directory, $filename) = $this->getDirectoryAndFilenameFromKey($cacheKey);

        if (file_exists($directory . "/" . $filename) && !is_dir($directory . "/" . $filename)) {
            return file_get_contents($directory . "/" . $filename);
        }

        return null;


    }
604823
protected function getDefaultStorageValue($sKey, $sDefaultValue = null)
    {
        if (empty($this->obDefaultStorage)) {
            return $sDefaultValue;
        }

        return $this->obDefaultStorage->get($sKey, $sDefaultValue);
    }
845088
public function get($key) {
        $filename = $key.'.cache';
        $file = $this->file_path_for_key($key);
        $ttl = $this->definition->get_ttl();
        $maxtime = 0;
        if ($ttl) {
            $maxtime = cache::now() - $ttl;
        }
        $readfile = false;
        if ($this->prescan && array_key_exists($filename, $this->keys)) {
            if ((!$ttl || $this->keys[$filename] >= $maxtime) && file_exists($file)) {
                $readfile = true;
            } else {
                $this->delete($key);
            }
        } else if (file_exists($file) && (!$ttl || filemtime($file) >= $maxtime)) {
            $readfile = true;
        }
        if (!$readfile) {
            return false;
        }
        // Open ensuring the file for reading in binary format.
        if (!$handle = fopen($file, 'rb')) {
            return false;
        }
        // Lock it up!
        // We don't care if this succeeds or not, on some systems it will, on some it won't, meah either way.
        flock($handle, LOCK_SH);
        $data = '';
        // Read the data in 1Mb chunks. Small caches will not loop more than once.  We don't use filesize as it may
        // be cached with a different value than what we need to read from the file.
        do {
            $data .= fread($handle, 1048576);
        } while (!feof($handle));
        // Unlock it.
        flock($handle, LOCK_UN);
        // Return it unserialised.
        return $this->prep_data_after_read($data);
    }
310705
protected function _processCache($sKey, $mContents)
    {
        // looking for cache meta
        $aCacheMeta = $this->getCacheMeta($sKey);
        $blSerialize = isset($aCacheMeta["serialize"]) ? $aCacheMeta["serialize"] : true;

        if ($blSerialize) {
            $mContents = serialize($mContents);
        } else {
            $mContents = "<?php\n//automatically generated file\n//" . date("Y-m-d H:i:s") . "\n\n\$_aCacheContents = " . var_export($mContents, true) . "\n?>";
        }

        return $mContents;
    }
63915
public function read($key)
    {
        $cacheFile = $this->getCachePath($key);

        clearstatcache(true, $cacheFile);
        if (file_exists($cacheFile)) {
            $cache = file_get_contents($cacheFile);
            $cache = json_decode($cache, true);
            if ($cache['ttl'] > time()) {
                $this->remainingTtl = $cache['ttl'] - time();
                return $cache['content'];
            } else {
                $this->purge($key);
            }
        }

        return false;
    }
758738
protected function getCacheContent($key = null)
    {
        if (!$this->cache instanceof CacheInterface) {
            return false;
        }
        if (isset($key) && ($result = $this->cache->get($key)) !== false) {
            if (is_array($result) && isset($result['placeholders'], $result['result'])) {
                $this->addMultiPlaceholders($result['placeholders']);
                $result = $result['result'];
            }

            return $result;
        }

        return false;
    }
713804
public function saved($sKey)
    {
        if (empty($sKey)) {
            return null;
        }

        $sKey = static::class.'@'.$sKey;

        $obCollection = CollectionStore::instance()->saved($sKey);
        if (empty($obCollection)) {
            return null;
        }

        return $obCollection;
    }