Set a key's time to live in seconds
@param string $key
@param int $seconds
@return boolean true if the timeout was set, false if key does not exist or the timeout could not be set
554896
public function expire($key, $seconds)
    {
        $this->init();
        $result = $this->driver->expire($key, $seconds);
        return (bool)$result;
    }
864083
public function setInterval(int $seconds, ?int $microseconds = null): void
    {
        if (func_num_args() === 1) {
            $microseconds = $seconds;
            $seconds      = 0;
        }

        Assert::notNull($microseconds, 'Cannot set $microseconds to null. Set to 0 for no microseconds.');
        parent::setInterval($seconds, $microseconds);

        $this->seconds      = $seconds;
        $this->microseconds = $microseconds;
    }
1372984
public function setTimeout(int $seconds, int $microseconds = 0): self
    {
        $this->timeout = (float) ($seconds . '.' . $microseconds);
        stream_set_timeout($this->resource, $seconds, $microseconds);
        return $this;
    }
1068420
public function wait($seconds = 30) {
        $seconds = max(0, intval($seconds));
        $this->commands = array_merge($this->commands, array("wait" => min($seconds, 30), "total_wait" => $seconds));
        return $this;
    }
373073
public function setClientTtl(int $seconds): self
    {
        $this->setMaxAge($this->getAge() + $seconds);

        return $this;
    }
881566
public function pExpire($key, $milliseconds) {
        return $this->getHandler($this->judge(__FUNCTION__))->pExpire($key, $milliseconds);
    }
663971
public function setex($key, $seconds, $value) {
        return $this->returnCommand(['SETEX'], $key, [$key, $seconds, $value]);
    }
7413
public function expire($key, $seconds, $cb = null)
    {
        $this->redis->expire($this->config->redisprefix->value . $key, $seconds, $cb);
    }
328570
public function set($key, $value, $seconds, $strict = true) {
        $set = $this->memcached->set($key, $value, $seconds);
        if (!$set && $strict) {
            throw new CacheSetException($key);
        }
    }
802531
public function has($key)
    {
        $values = $this->readFileContents();

        if (!array_key_exists($key, $values)) {
            return false;
        }

        $value = $values[$key];

        return (!$this->hasExpired($value[static::TTL], $value[static::CREATE_TIME]));
    }
176491
public function save(string $key, $value, int $seconds = 0): bool
    {
        if (empty($key)) {
            throw  new \ErrorException('"key" should not be empty!');
        } elseif (!$this->isEnable()) {
            return false;
        }

        $data = $this->read();
        if (!is_array($data)) {
            $data = array();
        }

        $data[$key] = $value;

        return parent::write($data, $seconds ? $seconds : $this->timeout);
    }
1327166
public static function lock($key, $timeout = 500) {
        /* @var $cache RedisCache */
        $cache = Pool::get(CacheInterface::class);
        try {
            if ($cache instanceof RedisCache) {
                $cache->open();
                $redis = $cache->redis;
                $script = "if(redis.call('setnx',  KEYS[1],ARGV[1])==1)then return redis.call('expire',KEYS[1],10) else 
            return 0 end";
                for ($i = 0; $i < $timeout / 5; $i++) {
                    $ok = $redis->eval($script, ["_RedisLocker_$key", 'lock_' . Context::id()], 1);
                    if ($ok) {
                        Pool::release($cache);
                        return true;
                    }
                    if (IS_SWOOLE) {
                        \Co::sleep(0.005);
                    } else {
                        sleep(0.005);
                    }

                }
            }
            Pool::release($cache);
        } catch (\RuntimeException $e) {
            Pool::release($cache);
            throw $e;
        } catch (\Error $e) {
            Pool::release($cache);
            throw $e;
        }
        return false;
    }
11963
public function expire($key, $seconds) {
        return $this->getHandler($this->judge(__FUNCTION__))->expire($key, $seconds);
    }
958933
public function setConnectionTimeout(float $seconds): self
    {
        $this->validateTimeout($seconds);
        $this->connectionTimeout = $seconds;

        return $this;
    }
1142851
public function setStreamTimeout($seconds)
    {
        if ($this->isConnected() === true) {
            if (is_numeric($seconds) === true) {
                try {
                    $timeout      = number_format($seconds, 3);
                    $seconds      = floor($timeout);
                    $microseconds = (($timeout - $seconds) * 1000);
                    return stream_set_timeout($this->streamSocket, $seconds, $microseconds);
                } catch (\Exception $e) {
                    return false;
                }
            }
        }

        return false;
    }
664403
public function put($key, $value, $seconds)
    {
        return $this->apc->put($this->prefix.$key, $value, $seconds);
    }
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;
    }