Read a key from the cache

@param string $key Identifier for the data
@return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
972472
public function read($key)
    {
        $key = $this->_key($key);

        $value = $this->_Redis->get($key);
        if (preg_match('/^[-]?\d+$/', $value)) {
            return (int)$value;
        }
        if ($value !== false && is_string($value)) {
            return unserialize($value);
        }

        return $value;
    }
545614
public function get($key)
    {
        $filename = $this->cacheDir . DIRECTORY_SEPARATOR . $this->processKey($key);

        if (is_file($filename) && is_readable($filename)) {
            if (@filemtime($filename) < (time() - $this->ttl)) {
                return null;
            } else {
                return unserialize($this->safelyReadData($filename));
            }
        }

        return null;
    }
75218
public function get($key) {
        $key = $this->conf['keyPrefix'] . $key;
        $s = $this->cache->get($key);
        if ($s === false) {
            X::logger()->trace("MCache miss $key");
            return false;
        }

        X::logger()->trace("MCache hit $key");
        /** @noinspection UnserializeExploitsInspection */
        return is_numeric($s) ? $s : unserialize($s);
    }
757927
public function get($key)
    {
        $filename = $this->_filename($key);
        if (!file_exists($filename)) {
            return false;
        }

        $tmp_value = file_get_contents($filename);
        $expire    = (int) substr($tmp_value, 13, 24);

        // echo time()."<br />\n";
        // echo $expire."<br />\n";
        // echo substr($tmp_value,23);exit;

        if ($expire != 0 && time() < $expire) {
            return unserialize(substr($tmp_value, 23));
        } else {
            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;
    }
611243
public function get($key)
    {
        $getResult = $this->getValue($key);
        $unserialized = @unserialize($getResult);

        if (Util::hasInternalExpireTime($unserialized)) {
            $getResult = $unserialized['v'];
        }

        return $getResult;
    }
321446
public function getData(string $key)
    {
        return ($key !== 'password' || $key !== 'salt' || $key !== 'remember_me') ? $this->data[$key] : false;
    }
1350821
public function get($key)
    {
        $prefixed = $this->prefix.$key;

        $cache = $this->table()->where('key', '=', $prefixed)->first();

        // If we have a cache record we will check the expiration time against current
        // time on the system and see if the record has expired. If it has, we will
        // remove the records from the database table so it isn't returned again.
        if (is_null($cache)) {
            return;
        }

        $cache = is_array($cache) ? (object) $cache : $cache;

        // If this cache expiration date is past the current time, we will remove this
        // item from the cache. Then we will return a null value since the cache is
        // expired. We will use "Carbon" to make this comparison with the column.
        if (Carbon::now()->getTimestamp() >= $cache->expiration) {
            $this->forget($key);

            return;
        }

        return unserialize($cache->value);
    }
472044
protected function retrieve($key)
    {
        if (!$this->has($key)) {
            return null;
        }

        $cache = file_get_contents($this->path . $key);

        // compare the timestamp to the current time when we read the file.
        if (time() >= substr($cache, 0, 10)) {
            $this->forget($key);
            return null;
        }

        return unserialize(substr($cache, 10));
    }
1274144
public function read($key)
    {
        $result = $this->mongoInstance->findOne(self::collection, ['key' => $key]);

        if (is_array($result) && isset($result['content'])) {
            $this->remainingTtl = $result['ttl']->toDateTime()->getTimestamp() - time();

            return $result['content'];
        }

        $this->remainingTtl = 0;
        return false;
    }
503513
public function get($key)
    {
        if (isset($this->cache[$key])) {
            list($expires, $value) = $this->cache[$key];
            if (!$expires || ($expires >= microtime(true))) {
                return $value;
            }
            unset($this->cache[$key]);
        }
        return false;
    }
593397
public function get($key)
    {
        $value = $this->memcached->get($this->prefix.$key);

        if ($this->memcached->getResultCode() == 0) {
            return $value;
        }
    }
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;
        }
    }
379585
private function loadFromCache($key)
    {
        $encoded = (string) $this
            ->cache
            ->fetch($key);

        try {
            return is_string($encoded)
                ? $this
                    ->encoder
                    ->decode($encoded)
                : null;
        } catch (Exception $e) {
            // Silent pass
        }

        return null;
    }
249237
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']) {
            $cacheFileData = gzuncompress($cacheFileData);
        }

        $cacheObj = json_decode($cacheFileData);

        // Unable to decode JSON (could happen if compression was turned off while compressed caches still exist)
        if ($cacheObj === null) {
            return false;
        }

        if (!function_exists('sys_getloadavg')) {
            throw new Exception('Your PHP installation does not support `sys_getloadavg` (Windows?). Please set `unixLoadUpperThreshold` to `-1` in your RWFileCache 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
            $content = $cacheObj->content;

            if (($unserializedContent = @unserialize($content)) !== false) {
                // Normal unserialization
                $content = $unserializedContent;
            } elseif ($content == serialize(false)) {
                // Edge case to handle boolean false being stored
                $content = false;
            }

            return $content;
        } else {
            // Cache item has expired
            return false;
        }
    }
466039
private function read($key)
    {
        $fname = $this->getObjectPath($key);
        if (file_exists($fname)) {
            $content = file_get_contents($fname);
            return unserialize($content);
        }
        return null;
    }
580055
protected function getKeyID($key)
    {
        $state = Versioned::get_reading_mode();
        if ($state) {
            return $key . '_' . md5($state);
        }
        return $key;
    }