Returns the remaining time to live of a key that has a timeout.

@param string $key

@return int Ttl in seconds.

@throws KeyNotFoundException
@throws \Exception
354421
public function getTtl($key)
    {
        if (!array_key_exists($key, $this->store)) {
            throw new KeyNotFoundException();
        }

        $getResult = $this->store[$key];
        $unserialized = @unserialize($getResult);

        if (!Util::hasInternalExpireTime($unserialized)) {
            throw new \Exception('Cannot retrieve ttl');
        }

        return $this->handleTtl($key, $unserialized['ts'], $unserialized['s']);
    }
497452
protected function getConnection($key)
    {
        $offset = crc32($key) % count($this->_globalServers);
        if ($offset < 0) {
            $offset = -$offset;
        }

        if (!isset($this->_globalConnections[$offset]) || feof($this->_globalConnections[$offset])) {
            $connection = stream_socket_client("tcp://{$this->_globalServers[$offset]}", $code, $msg, $this->timeout);
            if (!$connection) {
                throw new \Exception($msg);
            }
            stream_set_timeout($connection, $this->timeout);
            if (class_exists('\Workerman\Lib\Timer') && php_sapi_name() === 'cli') {
                $timer_id = \Workerman\Lib\Timer::add($this->pingInterval, function ($connection) use (&$timer_id) {
                    $buffer = pack('N', 8) . "ping";
                    if (strlen($buffer) !== @fwrite($connection, $buffer)) {
                        @fclose($connection);
                        \Workerman\Lib\Timer::del($timer_id);
                    }
                }, array($connection));
            }
            $this->_globalConnections[$offset] = $connection;
        }
        return $this->_globalConnections[$offset];
    }
791976
public function get($key) {
		// First, check to see if the result has been cached.
		if (!isset($this->_cache[$key])) {
			return FALSE;
		}

		// Second, check its freshness.
		if ($this->_cache[$key]['time'] < time() - self::$_lifespan) {
			return FALSE;
		}

		return $this->_cache[$key]['data'];
	}
1070360
public function isTimedOut($key)
    {
        // if the item is available and has timed out, return TRUE
        if (array_key_exists($key, $this->lifetime) && $this->lifetime[$key] < time()) {
            return true;
        }
        // else return FALSE
        return false;
    }
1365828
protected function getValue($key)
    {
        if (!array_key_exists($key, $this->store)) {
            throw new KeyNotFoundException();
        }

        $getResult = $this->store[$key];
        $unserialized = @unserialize($getResult);

        if (Util::hasInternalExpireTime($unserialized)) {
            $this->handleTtl($key, $unserialized['ts'], $unserialized['s']);

            $getResult = $unserialized['v'];
        }

        return $getResult;
    }
611243
public function get($key)
    {
        $getResult = $this->getValue($key);
        $unserialized = @unserialize($getResult);

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

        return $getResult;
    }
261532
public function get($key) {
        if (!isset($this->cache[$key]) OR $this->cache[$key]['ttl'] <= $this->getNow()) {
            return null;
        }
        return $this->cache[$key]['value'];
    }
1147758
public function getCache($key)
    {
        if ($this->sqlInitialized()) {
            if ($this->sql) {
                $_key = $this->sql->real_escape_string($key);
                if ($this->lifetime == self::IMMORTAL_LIFETIME) {
                    if ($response = $this->sql->query("
                        SELECT *
                            FROM `{$this->table}`
                            WHERE
                                `{$this->key}` = '$_key' AND
                                `expire` IS NULL
                    ")) {
                        if ($cache = $response->fetch_assoc()) {
                            return unserialize($cache[$this->cache]);
                        }
                    }
                } else {
                    $liveCache = date('Y-m-d H:i:s', time() - $this->lifetime);
                    if ($response = $this->sql->query("
                        SELECT *
                            FROM `{$this->table}`
                            WHERE
                                `{$this->key}` = '$_key' AND (
                                    (
                                        `timestamp` > '{$liveCache}' AND
                                        `expire` IS NULL
                                    ) OR (
                                        `expire` > NOW()
                                    )
                                )
                    ")) {
                        if ($cache = $response->fetch_assoc()) {
                            return unserialize($cache[$this->cache]);
                        }
                    }
                }
            }
            return false;
        }
    }
887561
public function get($key) {
        if (isset($this->store[$key])) {
            if ($this->ttl == 0) {
                $value = $this->store[$key][0];
                if ($this->maxsize !== false) {
                    // Make sure the element is now in the end of array.
                    $this->set($key, $value);
                }
                return $value;
            } else if ($this->store[$key][1] >= (cache::now() - $this->ttl)) {
                return $this->store[$key][0];
            } else {
                // Element is present but has expired.
                $this->check_ttl();
            }
        }
        return false;
    }
751193
public function getLastValue($key)
    {
        $nb = count($this->table);
        if ($nb>0) {
            return $this->table[$nb-1][$key];
        } else {
            return null;
        }
    }
525743
public function get($key)
    {
        if (!$this->has($key)) {
            throw new Exception(sprintf(Exception::STATS_KEY_NOT_EXISTS, $key));
        }

        return $this->getCachedStats()->offsetGet($key);
    }
1205512
public function getFlashed($key)
    {
        if ($this->has($key)) {
            // Save it before removing
            $value = $this->get($key);

            // And remove it
            $this->remove($key);
            return $value;
        } else {
            throw new RuntimeException(sprintf('Attempted to read non-existing session key "%s"', $key));
        }
    }
270168
public function expire($key, $seconds)
    {
        try {
            $value = $this->get($key);
        } catch (KeyNotFoundException $e) {
            return false;
        }

        return $this->getClient()->replace(
            $key,
            Util::getDataWithExpire($value, $seconds, time()),
            $seconds
        );
    }
95103
public function getTimestamp($key) {
		$key = $this->getRealKey ( $key );
		$cache = \apcu_cache_info ();
		if (empty ( $cache ['cache_list'] )) {
			return false;
		}
		foreach ( $cache ['cache_list'] as $entry ) {
			if ($entry ['info'] != $key) {
				continue;
			}
			$creationTime = $entry ['creation_time'];
			return $creationTime;
		}
		return \time ();
	}
593397
public function get($key)
    {
        $value = $this->memcached->get($this->prefix.$key);

        if ($this->memcached->getResultCode() == 0) {
            return $value;
        }
    }
941569
public function getValue(string $key)
    {
        if (!Config::get('activateDbCache')) {
            return false;
        }

        // clean expired values at first (self-purification)
        $this->database->prepare('DELETE FROM tl_db_cache WHERE expiration < ?')->execute(time());

        $result = $this->database->prepare('SELECT * FROM tl_db_cache WHERE cacheKey = ?')->execute($key);

        if ($result->numRows > 0) {
            return $result->cacheValue;
        }

        return false;
    }
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;
    }