Converts the given time to live value to a DataTime instance;

@param mixed $ttl The time-to-live value to validate.

@return integer
199579
private function getExpiration($ttl) : int
    {
        if ($ttl === null) {
            return PHP_INT_MAX;
        }

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

        return (new DateTime())->add($ttl)->getTimestamp();
    }
580007
public function getTtl()
    {
        if (false === $this->ttl) {
            $this->ttl = $this->getDefaultTtl();
        }

        return $this->ttl;
    }
541550
public static function normalizeExpireAt($ttl)
    {
        self::checkTtlType($ttl);

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

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

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

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

        return false;
    }
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;
    }
2710
protected function doSet(string $key, $value, int $ttl = 0)
    {
        if ($ttl > 0) {
            $ttl = \time() + $ttl;
        }

        $filename = $this->getFilename($key);
        $content = '<?php /* ' . Serialize::encode([
                'value' => $value,
                'expire' => $ttl,
            ]) . ' */';

        return $this->storage->put($filename, $content);
    }
223599
protected function ttlToMemcachedTime($ttl)
    {
        $seconds = $this->ttlToSeconds($ttl);

        if ($seconds <= 0) {
            return isset($seconds) ? false : 0;
        }

        /* 2592000 seconds = 30 days */
        return $seconds <= 2592000 ? $seconds : $this->ttlToTimestamp($ttl);
    }
409965
public function getAndPut(string $key, $data, int $ttl = 0)
	{
		$storedValue = $this->get($key);

		$this->put($key, $data, $ttl);

		return $storedValue;
	}
1055092
public function isEndTime($timeTtl)
    {
        $now = new \DateTime('now');
        $accessTime = date("Y-m-d H:i:s.", filemtime($this->filePath));
        $accessTime = new \DateTime($accessTime);
        $accessTime->modify(sprintf('+%s seconds', $timeTtl));

        if ($accessTime < $now) {
            return $this->createUnlock();
        } else {
            return true;
        }
    }
66227
public function set($key, $value, $ttl = null)
    {
        $ttl = is_null($ttl) ? $this->ttl : $ttl;

        return $this->client->set($this->getKey($key), $value, $ttl);
    }
1046423
protected function getSeconds($ttl)
    {
        $duration = $this->parseDateInterval($ttl);

        if ($duration instanceof DateTimeInterface) {
            $duration = Carbon::now()->diffInRealSeconds($duration, false);
        }

        return (int) $duration > 0 ? $duration : 0;
    }
247703
public function set($key, $data, $ttl)
    {
        $this->ttl = $ttl;

        $filename = $this->cacheDir . DIRECTORY_SEPARATOR . $this->processKey($key);

        return $this->safelyWriteData($filename, 'w', serialize($data));
    }
931030
public function save($ttl = 0)
	{
		$ttl = ($ttl)?:$this->ttl;
		if (empty($this->file)) {
			trigger_error('Unable to save. No file specified.');
			return false;
		}
		if(is_null($this->content)) {
			trigger_error(sprintf('Unable to save. Contents of file `%s´ is NULL.',$this->file));
			return false;
		}
		if ($this->changed) {
			$this->fs->write($this->file, (string) $this->content);
			if ($this->f3->get('CACHE')) {
				$cache = \Cache::instance();
				$cacheHash = $this->getCacheHash($this->file);
				if ($this->ttl)
					$cache->set($cacheHash,$this->content,$this->ttl);
				elseif ($cache->exists($cacheHash))
					$cache->clear($cacheHash);
			}
		}
		$this->changed = false;
		$this->metaHandle->save($this->file,$this->meta,$ttl);
		return true;
	}
1322231
private function normalizeTtl($ttl)
    {
        if ($ttl === null) {
            return self::DEFAULT_TTL; // Default TTL is one hour
        }

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

        if ($ttl instanceof DateInterval) {
            $currentDateTime = new \DateTimeImmutable();
            $ttlDateTime = $currentDateTime->add($ttl);

            return $ttlDateTime->getTimestamp() - $currentDateTime->getTimestamp();
        }

        throw new InvalidArgumentException('Invalid TTL: ' . print_r($ttl, true));
    }
909283
public function set($key, $value, $ttl = 60)
    {
        $dataType = gettype($value);

        switch ($dataType) {
            case 'array':
            case 'object':
                $value = serialize($value);
                break;
            case 'boolean':
            case 'integer':
            case 'double': // Yes, 'double' is returned and NOT 'float'
            case 'string':
            case 'NULL':
                break;
            case 'resource':
            default:
                return false;
        }

        if (!$this->redis->hMSet($key, ['type' => $dataType, 'value' => $value])) {
            return false;
        } elseif ($ttl) {
            $this->redis->expireAt($key, time() + $ttl);
        }

        return true;
    }
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;
    }
1349796
protected function filterTtl(&$ttl): void
    {
        if ($ttl !== null) {
            if ($ttl instanceof \DateInterval) {
                $ttl = (int) $ttl->format('%s');
            }
            $ttl = (int) $ttl;
        }
    }