Set cookie time-to-live.

@param int $ttl Cookie time-to-live.

@return $this
@throws InvalidArgumentException
970430
public function setCookieLifetime($ttl)
    {
        if (!is_null($ttl)
            && !is_numeric($ttl)
        ) {
            throw new InvalidArgumentException("No valid ttl provided");
        }

        $this->cookieLifetime = (int)$ttl;

        return $this;
    }
258773
public function set($key, $value, $ttl = 0)
    {
        $ttl = $this->fromDefaultTtl($ttl);

        if ($ttl >= 0) {
            $this->memcached->set($key, $value);

            if ($ttl > 0) {
                $this->memcached->touch($key, \time() + $ttl);
            }

            $this->setChain($key, $value, $ttl);
        }

        return $this;
    }
1210885
public function set($key, $value, $ttl = null)
    {
        $this->adapter->saveItem($key, $value, $ttl);

        return $this;
    }
1157748
public static function normalizeTtl($ttl)
    {
        self::checkTtlType($ttl);

        if (is_int($ttl)) {
            return $ttl;
        }

        if ($ttl instanceof DateInterval) {
            $now = new DateTimeImmutable;
            return $now->add($ttl)->getTimestamp() - $now->getTimestamp();
        }

        return null;
    }
1105002
public function set($key, $value, $ttl)
    {
        if ($value === false) {
            throw new InvalidValueException(['`:key` key cache value can not `false` bool value', 'key' => $key]);
        } elseif (is_scalar($value) || $value === null) {
            if (is_string($value) && $value !== '' && $value[0] !== '{' && $value[0] !== '[') {
                $data = $value;
            } else {
                $data = json_encode(['_wrapper_' => $value], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
            }
        } elseif (is_array($value) && isset($value['_wrapper_'])) {
            $data = json_encode(['_wrapper_' => $value], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        } else {
            $data = json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        }

        if ($data === false) {
            throw new InvalidValueException([
                '`:key` key cache value json_encode failed: `:code` `:message`',
                'key' => $key,
                'code' => json_last_error(),
                'message' => json_last_error_msg()
            ]);
        }

        $this->do_set($key, $data, $ttl);
    }
661269
public function setWithTtl($key, $value, $ttl) {
        if (is_resource($value))
            return false;

        if ($ttl != 0 && $ttl > 2592000) {
            $ttl -= time();
        }
        if ($ttl <= 0)
            return true;

        $key = $this->getUsedKey($key);
        $res = $this->_connection->set($key, $this->esc($value));

        if ($res !== 'OK') {
            return false;
        }

        return ($this->_connection->expire($key, $ttl) == 1);
    }
987227
public function gc($ttl) {
    $store  = $this->psl['store'];

    $Ids = $store->listIds('session');
    foreach($Ids as $Id) {
      $data = $store->meta('session', $Id);
      if($data->time + $ttl < time()) {
        $store->delete('session', $Id);
      }
    }
    return true;
  }
728539
protected function getTTL($ttl):?int{

		if($ttl instanceof DateInterval){
			return (new DateTime)->add($ttl)->getTimeStamp() - time();
		}
		else if((is_int($ttl) && $ttl > 0) || $ttl === null){
			return $ttl;
		}

		$msg = 'invalid ttl';
		$this->logger->error($msg);

		throw new InvalidArgumentException($msg);
	}
584756
public function set($key, $value, $ttl = null)
    {
        $values = $this->readFileContents();

        $values[$key] = [];

        $values[$key][self::VALUE] = $value;
        $values[$key][self::TTL] = $ttl;
        $values[$key][self::CREATE_TIME] = time();

        return $this->writeFileContents($values);
    }
69626
public function set($key, $value, $ttl = 0)
    {
        $key = (string)$key;
        $ttl = $this->fromDefaultTtl($ttl);

        if ($ttl >= 0) {
            $calculatedTtl = $this->getCalculatedTtl($ttl);

            self::$registry[$key] = [
                'value'   => $this->storageDataStructure($value),
                'expires' => new DateTime(\date('Y-m-d H:i:s', $calculatedTtl))
            ];
        }
        return $this;
    }
654131
protected function getTtlBSON($ttl): ?BSONUTCDatetime
    {
        return isset($ttl) ? new BSONUTCDateTime($this->ttlToTimestamp($ttl) * 1000) : null;
    }
1207455
public function set($key, $value, $ttl = 2592000)
    {
        if (!self::$instance) {
            self::getInstance();
        }

        $res = NULL;
        // Try to update existing
        if ($this->exists($key)) {
            $res = self::$memcached->set(CFG_DOMAIN . $key, $value, $ttl);
        } else {
            // Set new
            $res = $this->add($key, $value, $ttl);
        }
        return $res;
    }
314171
public static function set($key, $data, $ttl = self::TTL_NO_EXPIRY, $tags = [])
    {
        if (!$cache = self::getInstance()) {
            return false;
        }

        $key = self::prepare($key);
        try {
            $item = $cache->getItem($key);
            $item->set($data);

            if (self::TTL_NO_EXPIRY !== $ttl) {
                $item->expiresAfter($ttl);
            }

            if (!empty($tags)) {
                $item->setTags($tags);
            }

            return $cache->save($item);
        } catch (InvalidArgumentException $e) {
            // something going wrong
            Logger::error($e->getMessage());
        }

        return false;
    }
664206
public function setLifetime($lifetime)
    {
        $lifetime = intval($lifetime);

        if ($lifetime < 1 || $lifetime > 44640) {
            throw new InvalidArgument('Valid value ranges between 1 minute and 31 days given in minutes');
        }

        $this->lifetime = $lifetime;

        return $this;
    }
466288
public function update($value, $ttl = null)
    {
        $queryKeys = $this->prepareKeys(false);

        if (count($queryKeys)) {
            return $this->updateBatchProxy($queryKeys, $value, $ttl);
        }

        return false;
    }
217365
public function setTtl(int $ttl = 86400) : CNabuDataObject
    {
        if ($ttl === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$ttl")
            );
        }
        $this->setValue('nb_domain_zone_ttl', $ttl);
        
        return $this;
    }
719020
public function setResult($key, $result, $ttl)
    {
        if (!($ttl instanceof Ttl)) {
            $ttl = new Ttl($ttl);
        }

        $expirationTimestamp = time() + $ttl->getTtl();
        $value = new Value($result, $expirationTimestamp);

        $this->valueStore->set($key, $value, $ttl->getRealTtl());
    }