设置过期时间(秒)
@param int $seconds
@return bool 成功与否
358119
public function setExpire(int $seconds): bool
    {
        return $this->handle->expire($this->name, $seconds);
    }
422642
protected function secondsToString($seconds)
    {
        $seconds = (int) $seconds;

        $time = array();

        // get hours
        $hours = floor($seconds / 3600);
        $time[] = str_pad($hours, 2, '0', STR_PAD_LEFT);

        // get minutes
        $seconds = $seconds % 3600;
        $time[] = str_pad(floor($seconds / 60), 2, '0', STR_PAD_LEFT);

        // get seconds
        $time[] = str_pad($seconds % 60, 2, '0', STR_PAD_LEFT);

        return implode(':', $time);
    }
890784
public function put($key, $value, $seconds)
    {
        return $this->memcached->set(
            $this->prefix.$key, $value, $this->calculateExpiration($seconds)
        );
    }
534165
public final function addSeconds( int $seconds = 1 )
      : DateTime
   {

      return $this->move( new \DateInterval( 'PT' . \abs( $seconds ) . 'S' ), $seconds < 0 );

   }
1351100
public static function getOffsetBySeconds($seconds)
    {
        $tmp    = abs($seconds);
        $hour   = (int) ($tmp / 3600);
        $minute = (int) (($tmp % 3600) / 60);

        $result = $seconds < 0 ? '-' : '+';
        $result.= ($hour < 10  ? '0' . $hour   : $hour) . ':';
        $result.= $minute < 10 ? '0' . $minute : $minute;

        return $result;
    }
516329
public function get_recently_active_sessions($seconds=600) {
		if(is_null($seconds) || !is_numeric($seconds)) {
			$seconds = 10;
		}
		$sql = "SELECT session_id, uid, date_created, last_updated, num_checkins
			FROM cswal_session_table WHERE last_updated > NOW() - interval '". $seconds
				." seconds'";
		try {
			$retval = $this->db->run_query($sql);
		}
		catch(Exception $ex) {
			throw new Exception($ex);
		}
		
		return($retval);
	}
71245
public static function saveCache(string $key, $value, int $seconds = 0): bool
    {
        return self::getInstance()->save($key, $value, $seconds);
    }
1353869
public function get($key, $seconds = 60)
    {
        $result = $this->connection()->setnx($key, 1);

        if ($result === 1) {
            $this->connection()->expire($key, $seconds);
        }

        return $result === 1;
    }
997565
protected static function get_duration_text($seconds) {
        if (empty($seconds)) {
            return get_string('none');
        }
        $data = self::parse_seconds($seconds);
        switch ($data['u']) {
            case (60*60*24*7):
                return get_string('numweeks', '', $data['v']);
            case (60*60*24):
                return get_string('numdays', '', $data['v']);
            case (60*60):
                return get_string('numhours', '', $data['v']);
            case (60):
                return get_string('numminutes', '', $data['v']);
            default:
                return get_string('numseconds', '', $data['v']*$data['u']);
        }
    }
693239
public function cacheNoValidate($seconds = 60)
    {
        self::preventMultipleCaching();
        self::$cached = true;
        Header::cacheNoValidate($seconds);

        return $this;
    }
1177348
public function time_hms($seconds)
	{
		$time = '';

		// First pass
		$hours = (int) ($seconds / 3600);
		$seconds = $seconds % 3600;
		$minutes = (int) ($seconds / 60);
		$seconds = $seconds % 60;

		// Cleanup
		$time .= ($hours) ? $hours . ':' : '';
		$time .= ($minutes < 10 && $hours > 0) ? '0' . $minutes : $minutes;
		$time .= ':';
		$time .= ($seconds < 10) ? '0' . $seconds : $seconds;

		return $time;
	}
478342
public function setTtl(int $seconds, string $value = '')
        {
                if(!empty($value)) {
                        return $this->_redis->setex($this->_key, $seconds, $value);
                }
                return parent::setExpire($seconds);
        }
1198980
public function setSTSLifetime(int $seconds)
    {
        $seconds = $seconds;

        if ($seconds >= 900 && $seconds <= 3600) {
            $this->stsLifetime = $seconds;
        }
    }
1368413
public function timeout(int $seconds): self
    {
        return tap($this, function () use ($seconds) {
            return $this->options = array_merge_recursive($this->options, [
                'timeout' => $seconds,
            ]);
        });
    }
98797
public function isCreatedInLast(int $seconds = 86400, string $timezone = null): bool
    {
        if (!$this->hasCreatedAt()) {
            return false;
        }

        if ($timezone === null) {
            $timezone = 'UTC';
        }

        $date = $this->getCreatedAtDatetime($timezone);
        $now = new DateTime('now', new DateTimeZone($timezone));
        $now->modify("-{$seconds} seconds");

        return $date->getTimestamp() >= $now->getTimestamp();
    }
560231
public function expiresIn( int $seconds ) : Token
	{
		if ( $seconds > 0 )
		{
			$this->expiry = new DateTimeImmutable( sprintf( '+%d seconds', $seconds ) );

			return $this;
		}

		throw (new InvalidExpiryInterval())->withSeconds( $seconds );
	}
270168
public function expire($key, $seconds)
    {
        try {
            $value = $this->get($key);
        } catch (KeyNotFoundException $e) {
            return false;
        }

        return $this->getClient()->replace(
            $key,
            Util::getDataWithExpire($value, $seconds, time()),
            $seconds
        );
    }