Defines how long the query cache will be active before expire.

@param int $timeToLive How long the cache entry is valid.

@return Query This query instance.
512326
public function setQueryCacheLifetime($timeToLive)
    {
        if ($timeToLive !== null) {
            $timeToLive = (int) $timeToLive;
        }

        $this->queryCacheTTL = $timeToLive;

        return $this;
    }
792256
public function calculate_expiry($timestamp) {
        $expiry = null;

        if (isset($this->expiredate)) {
            $expiry = $this->expiredate;
        } else if (isset($this->expireperiod)) {
            $expiry = $timestamp + $this->expireperiod;
        }

        return $expiry;
    }
9272
protected function _store($data, $id, $timeToLive)
    {
        if (zend_disk_cache_store($this->_options['namespace'] . '::' . $id,
                                  $data,
                                  $timeToLive) === false) {
            $this->_log('Store operation failed.');
            return false;
        }
        return true;
    }
178421
private function isExpired($createTs, $lifetime) {
    if ($lifetime === null) {
      return false;
    }
    $expireDate = (new \DateTime())->setTimeStamp($createTs);
    if (intval($lifetime)) {
      $expireDate = $expireDate->modify('+'.$lifetime.' seconds');
    }
    return $expireDate < new \DateTime();
  }
1286618
private function isExpired($timestamp, $expiration)
    {
        $result = false;
        if ($expiration !== 0) {
            $timeDiff = time() - $timestamp;
            $result = ($timeDiff > $expiration) ? true : false;
        }

        return $result;
    }
305664
public static function validateCache($file, $cacheTTL, $cacheForever)
    {
        $currentTime = time();
        $expireTime  = $cacheTTL * 60 * 60;
        $fileTime    = filemtime($file);
        return ($currentTime - $expireTime < $fileTime)
                or $cacheForever;
    }
304923
public function useResultCache($useCache, $cacheLifetime = null)
    {
        $this->useResultCache = $useCache;
        $this->cacheLifetime = $cacheLifetime;
        return $this;
    }
262286
public function set($key, $value, $timeToLive = null) {
		$filename = $this->getFileName($key);
		//$this->log->trace("Storing value in cache: key '$key', value '".var_export($value, true)."'");
		if ($this->log) {
			if ($this->log instanceof LoggerInterface) {
				$this->log->info("Storing value in cache: key '{key}'", array('key'=>$key));
			} else {
				$this->log->trace("Storing value in cache: key '$key'");
			}
		}

        $oldUmask = umask(0);

		if (!is_writable($filename)) {
			if (!file_exists($this->getDirectory())) {
				mkdir($this->getDirectory(), 0777, true);
			}
		}
		
		if ($timeToLive == null) {
			if (empty($this->defaultTimeToLive)) {
				$timeOut = 0;
			} else {
				$timeOut = time() + $this->defaultTimeToLive;
			}
		} else {
			$timeOut = time() + $timeToLive;
		}

		$data = array(
			'lifetime'  => $timeOut,
			'data'      => $value
		);

        $serializeData = serialize($data);
        if(strpos($serializeData, 'r:') !== false || (is_object($value) && !method_exists($value, '__set_state'))){
            $code   = sprintf('<?php return unserialize(%s);', var_export($serializeData, true));
            file_put_contents($filename, $code);
        }else{
            $data  = var_export($data, true);
            $code   = sprintf('<?php return %s;', $data);
            file_put_contents($filename, $code);
        }

        // Cache is shared with group, not with the rest of the world.
        chmod($filename, 0660);

        umask($oldUmask);
	}
542962
protected function isCacheExpired($fromCurrency, $toCurrency)
    {
        $cacheCreationTime = $this->getCacheCreationTime($fromCurrency, $toCurrency);
        return (time() - $cacheCreationTime) > $this->getCacheTimeOut()->format('%s');
    }
1065536
final public function expireat($key, $ttl) {
		$res = $this->connection->expireat($key, $ttl);
		self::$logger->info(sprintf(
			"Redis: expireat %s: %s.", $key, $ttl));
		return $res;
	}
587928
private function getControledExpireTime($expire)
    {
        $lifetime = $this->getControledLifetime($expire - time());

        if (0 < $lifetime) {
            return time() + $lifetime;
        }

        return $expire;
    }
353586
public function expireat($key, $timestamp)
    {
        $this->init();
        $result = $this->driver->expireat($key, $timestamp);
        return (bool)$result;
    }
1087525
public function setLastVisit($timestamp = 'now')
	{
		$timestamp = new Date($timestamp);

		$query = $this->getQuery()
			->update($this->getTableName())
			->set(array('lastvisitDate' => $timestamp->toSql()))
			->whereEquals('id', $this->get('id'));

		return $query->execute();
	}
704163
public function getCacheLifetime()
    {
        $lifetime = $this->getContainer('config')->get('rinvex.repository.cache.lifetime');

        // Return value even if it's zero "0" (which means cache is disabled)
        return ! is_null($this->cacheLifetime) ? $this->cacheLifetime : $lifetime;
    }
336474
public function setExpiry(int $expires = null):AccessToken{
		$now = time();

		if($expires!== null){
			$expires =  intval($expires);
		}

		$this->expires = self::EOL_UNKNOWN;

		if($expires === 0 || $expires === self::EOL_NEVER_EXPIRES){
			$this->expires = self::EOL_NEVER_EXPIRES;
		}
		elseif($expires > $now){
			$this->expires = $expires;
		}
		elseif($expires > 0 && $expires < self::EXPIRY_MAX){
			$this->expires = $now + $expires;
		}

		return $this;
	}
222439
protected function getCacheExpiresTime($time = null)
    {
        if ($time === self::EXPIRES_END_OF_DAY) {
            return class_exists(Carbon::class)
                ? round(Carbon::now()->secondsUntilEndOfDay() / 60)
                : $this->cacheMinutes;
        }

        return $time ?: $this->cacheMinutes;
    }
234601
public static function timeOf($key)
    {
        static::$with_meta = true;

        $cache = static::get($key);

        static::$with_meta = false;

        if ($cache == null) {
            return false;
        }

        return $cache['__bow_meta']['expire_at'];
    }