The garbage collection function invoked by PHP.
@param  int     $lifetime The lifetime param, defaults to 1440 seconds in PHP.
@return boolean True always.
188674
public function gc($lifetime = 0)
    {
        $timeout = $this->getConfig('timeout');

        //find all sessions that are older than $timeout
        $olderThan = time() - $timeout;

        //no ack required
        $this->sessions->remove(
            array('last_accessed' => array('$lt' => new MongoDate($olderThan))),
            ( (class_exists('MongoClient')) ? (array('w'=>0)) : (array('safe'=>false)) )
        );

        return true;
    }
225725
public static function lifetime($lifetime = null, string $storage = 'global'): int
    {
        if ($lifetime !== null) {
            $seconds = strtolower((string)$lifetime);

            // Convert to minutes if hour.
            if (substr($seconds, -1) === 'h') {
                $seconds = (intval($seconds) * 60) . 'm';
            }

            // Convert to seconds if minutes.
            if (substr($seconds, -1) === 'm') {
                $seconds = (intval($seconds) * 60) . 's';
            }

            if (!is_array(self::$seconds)) {
                self::$seconds = [];
            }
            self::$seconds[$storage] = intval($seconds);
        }
        if (isset(self::$seconds[$storage])) {
            return self::$seconds[$storage];
        }
        return 0;
    }
499477
public function collectGarbage()
    {
        if ($this->inactivityTimeout === 0) {
            return 0;
        }
        if ($this->metaDataCache->has('_garbage-collection-running')) {
            return false;
        }

        $sessionRemovalCount = 0;
        $this->metaDataCache->set('_garbage-collection-running', true, [], 120);

        foreach ($this->metaDataCache->getIterator() as $sessionIdentifier => $sessionInfo) {
            if ($sessionIdentifier === '_garbage-collection-running') {
                continue;
            }
            $lastActivitySecondsAgo = $this->now - $sessionInfo['lastActivityTimestamp'];
            if ($lastActivitySecondsAgo > $this->inactivityTimeout) {
                if ($sessionInfo['storageIdentifier'] === null) {
                    $this->logger->warning('SESSION INFO INVALID: ' . $sessionIdentifier, $sessionInfo + LogEnvironment::fromMethodName(__METHOD__));
                } else {
                    $this->storageCache->flushByTag($sessionInfo['storageIdentifier']);
                    $sessionRemovalCount++;
                }
                $this->metaDataCache->remove($sessionIdentifier);
            }
            if ($sessionRemovalCount >= $this->garbageCollectionMaximumPerRun) {
                break;
            }
        }

        $this->metaDataCache->remove('_garbage-collection-running');
        return $sessionRemovalCount;
    }
812786
public function gc(int $maxlifetime) : bool
    {
        static $stmt;
        if (!isset($stmt)) {
            $stmt = $this->pdo->prepare(
                "DELETE FROM cesession_session WHERE dateactive < ?"
            );
        }
        $stmt->execute([date('Y-m-d H:i:s', strtotime("-$maxlifetime second"))]);
        return ($affectedRows = $stmt->rowCount()) && $affectedRows;
    }
956819
public function gc($maxlifetime)
    {
        return ($this->newQuery()->where('timestamp', '<', time() - $maxlifetime)->delete())
            ? $this->_success
            : $this->_fail();
    }
804997
public function set($key, $value, $lifeTime = 3600)
    {
        if (!$this->isEnabled()) {
            return false;
        }

        return $this->server->set($this->prefix . $key, $value, false, $lifeTime);
    }
1301307
public function gc($maxlifetime)
    {
        $timestamp = time() - $maxlifetime;

        if ($this->disableLog) {
            Log::temporaryDisable('sql');
        }

        try {
            $this->getAdapter()->delete($this->getTableName())->where('time', '<', $timestamp)->exec();
            return true;

        } catch (DbException $e) {
            Log::emergency($e);
            return false;

        } finally {
            if ($this->disableLog) {
                Log::restoreTemporaryDisablement();
            }
        }
    }
52917
public function purge($lifetime = LibSessionsDomainEntitySession::MAX_LIFETIME, $guestOnly = true)
    {
        $past = time() - $lifetime;

        $query = $this->getQuery()->delete()->where('time < '.$past);

        if ($guestOnly) {
            $query->where('guest', '=', 1);
        }

        return (boolean) $this->getStore()->execute($query);
    }
423497
public function gc($lifeTime = 0)
    {
        if (Config::get('session_user_loc') == 'db') {
            $lifeTime || $lifeTime = $this->lifeTime;
            $this->handler->whereLt('ctime', Cml::$nowTime - $lifeTime)
                ->delete(Config::get('session_user_loc_table'), true, Config::get('session_user_loc_tableprefix'));
        } else {
            //cache 本身会回收
        }
        return true;
    }
965632
public function store($key, $data, $lifetime = 0)
    {

        if ($lifetime != 0) {
            $lifetime = \time() + $lifetime;
        }

        $data = array($lifetime, $data);

        $this->hash[$key] = $data;

        if ($key != $this->catalog_key) {
            $this->catalogKeyAdd($key, $lifetime);
        }

        return true;
    }
1009097
public function gc($maxlifetime = null)
    {
        $result = false;

        if ($this->getTable()->isConnected())
        {
            $query = $this->getObject('lib:database.query.select')
                ->where('time < :time')
                ->bind(array('time' => (int)(time() - $maxlifetime)));

            $result = $this->_table->select($query, KDatabase::FETCH_ROWSET)->delete();
        }

        return $result;
    }
568534
public function gc($maxlifetime)
    {
        foreach ($this->sessions as $session_id => $content) {
            if ($this->sessions[$session_id]['time'] <= $this->createTimestamp()) {
                $this->destroy($session_id);
            }
        }

        return true;
    }
931318
public static function prolong($name, $lifetime)
    {
        $item = static::reach($name);

        if ($item['lifetime'] > 0) {
            $item['lifetime'] += $lifetime;
        } elseif ($item['lifetime'] == 0) {
            $item['lifetime'] = time() + $lifetime;
        }

        static::$register[$name] = $item;

        static::save();

        return true;
    }
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;
    }
419350
public function getLifetime()
    {
        if ($this->lifetime === null) {
            $this->lifetime = $this->config->get('system.cache.lifetime') ?: 604800; // 1 week default
        }

        return $this->lifetime;
    }
1186261
protected function resolveCacheLifetime($lifetime): DateTime
    {
        if ($lifetime instanceof DateTime) {
            return $lifetime;
        }

        if (is_int($lifetime)) {
            return Carbon::now()->addMinutes($lifetime);
        }
    }
343215
public function useResultCache($bool, $lifetime = null, $resultCacheId = null)
    {
        if ($bool) {
            $this->setResultCacheLifetime($lifetime);
            $this->setResultCacheId($resultCacheId);

            return $this;
        }

        $this->_queryCacheProfile = null;

        return $this;
    }