Get expiration from key.

@param string $key
@param string $storage Default 'global'.
@return int If not set, null is returned.
497997
public static function expiration(string $key, ?string $storage = 'global'): ?int
    {
        if (!self::has($key)) {
            return null;
        }

        // Get content.
        $fileKey = self::key($key);
        $content = null;
        if (file_exists(self::$path . '/' . $storage . '/' . $fileKey)) {
            $content = file_get_contents(self::$path . '/' . $storage . '/' . $fileKey);
        }

        // Extract expiration.
        $markerPos = strpos($content, self::$marker);
        $expiration = null;
        if ($markerPos !== false) {
            $expiration = intval(substr($content, 0, $markerPos));
        }

        return $expiration;
    }
48461
public function &__get($key)
    {
        $result = null;

        if ($key == 'name') {
            $result = $this->_name;
        }

        if ($key == 'expire') {
            $result = $this->_expire;
        }

        if ($key == 'path') {
            $result = $this->_path;
        }

        return $result;
    }
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');
    }
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;
    }
1091347
public function expire(Memento\Key $key = null)
    {
        $this->__connect($key);
        $expiresKey = $this->groupKey ? $this->groupKey : $key;
        $this->redis->hset($expiresKey->getKey(), Memento\Hash::FIELD_EXPIRES, 0);

        return (0 === intval($this->redis->hget($expiresKey->getKey(), Memento\Hash::FIELD_EXPIRES)));
    }
1009545
public function get($key)
    {
        if (!isset($this->records[$key])) {
            return null;
        }

        $record = $this->records[$key];

        if ($record['expire'] < time()) {
            unset($this->records[$key]);

            return null;
        }

        return $record['nodes'];
    }
709476
public function &offsetGet($key)
    {
        $ret = null;

        if (!$this->offsetExists($key)) {
            return $ret;
        }

        $ret =& $this->storage[$key];

        return $ret;
    }
1300137
protected function retrieve($key)
        {
            $this->_cleanCache();
            $res = Data::query('cache', 'key = ' . $key . ' && namespace = ' . $this->namespace . ' && expiration > ' . time());
            if (!count($res)) {
                return null;
            }
            $obj = Data::getObject(current($res));

            return $obj->getValue();
        }
637829
function isExpired (key) {
  const expireKey = `${expire}${key}`
  return storage
    .get(expireKey)
    .then(time => Promise.resolve(Date.now() >= new Date(time).getTime(), time))
}
889181
public function expire(Memento\Key $key = null)
    {
        $expiresFile = $this->getExpiresPath($key) . DIRECTORY_SEPARATOR . self::FILENAME_EXPIRES;

        $bytes = 0;
        $now = time();
        $expires = $now;
        if (file_exists(dirname($expiresFile))) {
            $bytes = file_put_contents($expiresFile, $expires, LOCK_EX);
        }

        return ($bytes > 0);
    }
316664
public function get($key, $expiration = false)
    {
        $item = $this->psr6Cache->getItem($key);

        return $item->isHit() ? $item->get() : false;
    }
1019967
public function get($key, $default = null)
	{
		// check if we have this key
		if (parent::has($this->prefixKey($key)))
		{
			// do we have expiry information?
			if ( ! isset($this->data[static::EXPIRE_DATA_KEY][$key]))
			{
				// nope, simply return the data
				return parent::get($this->prefixKey($key), $default);
			}

			// return the data if we don't have expiry information or if the data is valid
			if ($this->data[static::EXPIRE_DATA_KEY][$key][1] !== static::EXPIRE_STATE_EXPIRED)
			{
				// check the expiry strategy
				if ($this->data[static::EXPIRE_DATA_KEY][$key][0] === EXPIRE_ON_GET)
				{
					// expire on get, so expire it
					$this->data[static::EXPIRE_DATA_KEY][$key][1] = static::EXPIRE_STATE_EXPIRED;
				}

				// return the data
				return parent::get($this->prefixKey($key), $default);
			}
		}

		// no dice, return the default
		return $default;
	}
281408
public function get(string $key)
    {
        if (!isset($this->data[$key])) {
            return null;
        }

        $struct = $this->data[$key];

        if ($struct->ttl !== null) {
            $expire = \time() + $struct->ttl;
            if ($struct->expire < $expire) {
                $struct->expire = $expire;
                $this->queue->insert([$key, $struct->expire], -$struct->expire);
            }
        }

        return $struct->data;
    }
183541
protected function expire($key = array(), $ttl = 0)
    {
        if ($ttl === 0) {
            // when storing indefinitely, there's no point in keeping it around,
            // it won't just expire
            return;
        }

        // $key can be both string (1 key) or array (multiple)
        $keys = (array) $key;

        $time = time() + $ttl;
        foreach ($keys as $key) {
            $this->expires[$key] = $time;
        }
    }
44150
public function getByKey($key)
    {
        $storage = $this->getStorage();

        return isset($storage[$key]) ? $storage[$key] : null;
    }
1309531
public function get($key = null, $default = null)
    {
        if (is_null($key)) {
            return $this->all();
        }

        return $this->offsetExists($key) ? $this->storage[$key] : $default;
    }
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;
    }