Read from cache

@param string $key
@return mixed|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;
    }
535971
private function getCache($key)
    {
        $cache = $this->client->getItem($key);
        if ($cache->isHit()) {
            return $cache->get();
        }

        return null;
    }
1039255
protected function getData($key)
    {
        $cacheKey = $this->key($key);
        return array_key_exists($cacheKey, $this->cache)?$this->cache[$this->key($key)]:false;
    }
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;
        }
    }
1096629
public function get($key)
    {
        $file = $this->makePath($key);
        if (!($data = @file_get_contents($file))) {
            return false;
        }

        if (!($data = @unserialize($data))) {
            $this->delete($key); /* Delete corrupted. */
            return false;
        }

        list($expiry, $value) = $data;
        if ($expiry !== false && ($expiry < microtime(true))) {
            $this->delete($key);
            return false;
        }

        return $value;
    }
303388
public function getItem($key)
	{
		$table = $this->getTableCache();

		if (array_key_exists($key, $table)) {
			return $table[$key];
		} else {
			return false;
		}
	}
29661
public function GetCache($key)
    {
		return (array_key_exists($key, $this->_cache) ? $this->_cache[$key] : null);
	}
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;
    }
46742
public function read(string $key): array
    {
        return $this->useRedis(function($resource, $redis) use($key){
            $result = $redis->hget($this->getStoreKey(), $key);
            return $result ? $result : [];
        });
    }
789007
function read($key)
    {
        if (array_key_exists($key, $this->cache)) {
            return $this->cache[$key];
        }

        return $this->read_record($key, true);
    }
1163684
private function read($key)
    {
        $_jsonFile = $this->_root.$key.'.json';
        if(empty($this->_nr[$key])) {
            if (file_exists($_jsonFile)) {
                $_ar = @file_get_contents($_jsonFile);
                $ar = json_decode($_ar,true);
            } else {
                $ar = array();
            }
            $this->_nr[$key] = $ar;
        }
        return $this;
    }
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;
    }
1054468
public function get($key)
    {
        $position = $this->getPosition($key);
        if (false !== $position) {
            return [$key => $this->file->read($position)];
        }

        return false;
    }
94621
public function get($key)
	{
	    $value = static::getRaw($key);
        
	    //\Wslim\Ioc::logger('cache')->debug(sprintf('get: %s %s', $key, print_r($this, true)));
	    
		$value = $this->decodeValue($value);
		
		return $value;
	}
1188442
public function get($key)
    {
        if (empty($this->memcache)) {
            return false;
        }

        $key = $this->processKey($key);

        $data = $this->memcache->get($key);

        return $data;
    }
1245180
public function get($key)
    {
        $file = $this->getFilePath($key);

        if (file_exists($file)) {
            $data = file_get_contents($file);

            if (!empty($data)) {
                return $data;
            }
        }

        return false;
    }
542798
public function fetch($key)
    {
        $file_name = $this->getFilePath($key);
        if (!\file_exists($file_name) || !\is_readable($file_name)) {
            return false;
        } else {
            $h = \fopen($file_name, 'r');
            //lock file
            \flock($h, LOCK_SH);
        }

        $data = \file_get_contents($file_name);

        //release lock
        \fclose($h);

        $data = @\unserialize($data);

        //check to see if it expired
        if ($data && ($data[0] == 0 || time() <= $data[0])) {
            return $data[1];
        } else {
            $this->delete($key);
            return false;
        }

        return $data[1];
    }