Read content from cache

@param string $key

@return mixed
349924
public function read($key)
    {
        if (!isset($this->cacheDirectory)) {
            return;
        }

        $this->loadCacheMetaData();

        return unserialize(file_get_contents($this->cacheDirectory . '/' . $key));
    }
691244
function getCache( $key ) {

        return isset( $this->_cache[ $key ] ) ? $this->_cache[ $key ] : null;

    }
783923
public function read($key)
	{
		// Get data from memory storage
		$data = $this->memoryStorage->read($key);
		if ($data !== null) {
			return $data;
		}

		// Get data from cached storage and write them to memory storage
		$data = $this->cachedStorage->read($key);
		if ($data !== null) {
			$this->memoryStorage->write($key, $data, []);
		}

		return $data;
	}
458821
public static function get($key)
    {
        if (!self::$instance) return null;

        return self::$instance->cache->get($key);
    }
1127057
public function get($key)
    {
        $file=$this->getCacheDir().$key;
        if(file_exists($file)){
            $content=file_get_contents($file);
            $content=unserialize($content);
            return $content;
        }
        return null;
    }
676951
private function load($key)
    {
        $path = $this->getPath($key);

        return file_exists($path) ? file_get_contents($path) : false;
    }
617668
public function read($key) {
        return isset($_SESSION[$this->prefix . $key]) ? $_SESSION[$this->prefix . $key] : null;
    }
963525
public function get($key)
    {
        $filePath = $this->getFilePathFromKey($key);

        if (!file_exists($filePath)) {
            return false;
        }

        if (!is_readable($filePath)) {
            return false;
        }

        $cacheFileData = file_get_contents($filePath);

        if ($this->config['gzipCompression']) {
            try {
                $cacheFileData = gzuncompress($cacheFileData);
            } catch (\Exception $e) {
                $cacheFileData = false;
            }
        }

        // Bail immediately if the file could not be read, or its data could not be uncompressed
        if (!$cacheFileData) {
            return false;
        }

        $cacheObj = json_decode($cacheFileData);

        // Unable to decode JSON
        if ($cacheObj === null) {
            return false;
        }

        // Check cache object format
        if (!isset($cacheObj->content) || !isset($cacheObj->expiryTimestamp)) {
            return false;
        }

        // Check cache content is serialized
        if (!$this->isSerialized($cacheObj->content)) {
            return false;
        }

        if (!function_exists('sys_getloadavg') && $this->config['unixLoadUpperThreshold'] !== -1) {
            throw new Exception('Your PHP installation does not support `sys_getloadavg` (Windows?). Please set `unixLoadUpperThreshold` to `-1` in your DOFileCache config.');
        }

        if ($this->config['unixLoadUpperThreshold'] == -1) {
            $unixLoad = [0 => -PHP_INT_MAX, 1 => -PHP_INT_MAX, 2 => -PHP_INT_MAX];
        } else {
            $unixLoad = sys_getloadavg();
        }

        if ($cacheObj->expiryTimestamp > time() || $unixLoad[0] >= $this->config['unixLoadUpperThreshold']) {
            // Cache item has not yet expired or system load is too high
            return unserialize($cacheObj->content);
        } else {
            // Cache item has expired
            return false;
        }
    }
506753
public function read(string $key)
    {
        if (isset($this->cache[$key])) {
            $expire = (int)$this->cache[$key]['ttl'];

            if ($expire === 0 || time() < $expire) {
                return $this->cache[$key]['data'];
            }

            $this->delete($key);
            return false;
        }

        return false;
    }
262091
protected function read($key)
    {
        $path = $this->path($key);
        try {
            $data = $this->filesystem->read($path);
        } catch (FileNotFoundException $e) {
            // unlikely given previous 'exists' check, but let's play safe...
            // (outside process may have removed it since)
            return false;
        }

        if ($data === false) {
            // in theory, a file could still be deleted between Flysystem's
            // assertPresent & the time it actually fetched the content
            // extremely unlikely though
            return false;
        }

        $data = explode("\n", $data, 2);
        $data[0] = (int) $data[0];

        return $data;
    }
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);
    }
403056
protected function getItem($key)
    {
        $cache_file = $this->path($key);
        if (!file_exists($cache_file) || !is_readable($cache_file)) {
            return false;
        }

        $data = file_get_contents($cache_file);
        if (empty($data)) return false;
        $cache_data = unserialize($data);

        if ($cache_data === false) {
            return false;
        }

        $check_expire = $this->checkExpire($cache_data);
        if ($check_expire === false) {
            $this->delete($key);
            return false;
        }

        return $cache_data;
    }
454925
public function get($key) {
        $file = $this->key2file($key);
        if (is_file($file)) {
            /** @noinspection PhpIncludeInspection */
            $r = require $file;
            if (!empty($r) && $key === $r['key'] && (0 === $r['expiration'] || time() <= $r['expiration'])) {
                X::logger()->trace("CCache hit $key");
                return $r['data'];
            }
        }
        X::logger()->trace("CCache miss $key");
        return false;
    }
1245248
protected function retrieve($key)
        {
            if (!File::exists($this->path . $key)) {
                return null;
            }

            // File based caches store have the expiration timestamp stored in
            // UNIX format prepended to their contents. We'll compare the
            // timestamp to the current time when we read the file.
            if (time() >= substr($cache = fgc($this->path . $key), 0, 10)) {
                return $this->forget($key);
            }

            return unserialize(substr($cache, 10));
        }
1201056
private function fetch($key)
    {
        $keyExp = explode('.', $key);

        if ($this->cache->has($key))
        {
            return $this->cache->get($key);
        }


        $row = $this->database
            ->table($this->config['db_table'])
            ->where('setting_key', $keyExp[0])
            ->first(['setting_value']);

        if ( ! is_null($row))
        {
            $setting_value = json_decode($row->setting_value, true);
            $value         = set_nested_array_value($setting_value, $keyExp);

            return $this->cache->set($key, $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;
    }
1044959
public function get($key)
    {
        $connection = $this->getConnection($key);
        $this->writeToRemote(array(
            'cmd' => 'get',
            'key' => $key,
        ), $connection);
        return $this->readFromRemote($connection);
    }