Garbage Collection

@param int $maxlifetime
@return true
433508
public function gc($maxlifetime)
    {
        $sessions = $this->entityManager->getRepository($this->entityName)->findAll();
        foreach ($sessions as $session) {
            if ($this->_getExpirationTime($session) < time()) {
                $this->entityManager->remove($session);
            }
        }

        try {
            $this->entityManager->flush();
            return true;
        } catch (\Doctrine\ORM\OptimisticLockException $exc) {
            return false;
        }
    }
972791
public function gc($maxLife): bool
    {
        try {
            $this->storageDriver->clearOld($maxLife * 1000000);
            return true;
        } catch (Exception $e) {
            return false;
        }
    }
1167885
public function gc( $maxLifeTime )
    {
        ezpEvent::getInstance()->notify( 'session/gc', array( $maxLifeTime ) );
        $db = eZDB::instance();
        $gcCompleted = true;
        eZSession::triggerCallback( 'gc_pre', array( $db, $maxLifeTime ) );

        if ( $this->gcSessionsPrIteration )
        {
            $timedOut = false;
            $maxExecutionTime = ini_get( 'max_execution_time' );
            if ( !$maxExecutionTime )
            {
                if ( PHP_SAPI === 'cli' )
                    $maxExecutionTime = self::GC_MAX_EXECUTION_TIME_CLI;
                else
                    $maxExecutionTime = self::GC_MAX_EXECUTION_TIME;
            }

            do
            {
                $startTime = time();
                $rows = $db->arrayQuery( 'SELECT session_key FROM ezsession WHERE expiration_time < ' . $maxLifeTime ,  array( 'offset' => 0, 'limit' => $this->gcSessionsPrIteration, 'column' => 'session_key' ) );
                if ( $rows )
                {
                    $keyINString = '\'' . implode( '\', \'', $rows ) . '\'';// generateSQLINStatement does not add quotes when casting to string
                    $db->query( "DELETE FROM ezsession WHERE session_key IN ( $keyINString )" );

                    $stopTime = time();
                    $remaningTime = $maxExecutionTime - self::GC_TIMEOUT_MARGIN - ( $stopTime - $maxLifeTime );
                    if ( $remaningTime < ( $stopTime - $startTime ) )
                    {
                        $timedOut = true;
                        break;
                    }
                }
            } while ( $rows );
            $gcCompleted = !$timedOut || !$rows;
        }
        else
        {
            $db->query( 'DELETE FROM ezsession WHERE expiration_time < ' . $maxLifeTime );
        }

        eZSession::triggerCallback( 'gc_post', array( $db, $maxLifeTime ) );
        return $gcCompleted;
    }
192958
protected function garbageCollect()
    {
        foreach (Finder::create()->files()->name('*.json')->date('< ' . $this->gc_lifetime . ' hour ago')->in(
            $this->dirname
        ) as $file) {
            $this->files->delete($file->getRealPath());
        }
    }
832812
public function purge($maxLifetime = 1440)
	{
		$past = time() - $maxLifetime;
		$query = $this->_db->getQuery(true)
			->delete($this->_db->quoteName($this->_tbl))
			->where($this->_db->quoteName('time') . ' < ' . (int) $past);
		$this->_db->setQuery($query);

		return $this->_db->execute();
	}
1001534
public function getLifetime() {
        if (!self::$lifetime) {
            $sessionExpirationHours = engineGet('Config', 'sessionExpirationHours', false);
            if (!$sessionExpirationHours)
                $sessionExpirationHours = 2;
            self::$lifetime = 60 * 60 * $sessionExpirationHours;
        }

        return self::$lifetime;
    }
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;
    }
1324093
public function gc() 
	{
		$lifetime = \CCArr::get( 'lifetime', $this->_config, \CCDate::minutes( 5 ) );
		
		if ( $lifetime < ( $min_lifetime = \CCArr::get( 'min_lifetime', $this->_config, \CCDate::minutes( 5 ) ) ) )
		{
			$lifetime = $min_lifetime;
		}
		
		$this->_driver->gc( $lifetime );
	}
428239
public function isExpired($lifetime)
    {
        $interval = $this->createdOn->diff(new \DateTimeImmutable());

        return $interval->s >= (int) $lifetime;
    }
293132
protected function garbage_collection() {
        if (empty($this->session)) {
            return true;
        }
        foreach ($this->session as $key=>$cachedinfo) {
            if (is_array($cachedinfo) && $cachedinfo[self::CACHETIME]<$this->timeout) {
                unset($this->session[$key]);
            }
        }
    }
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);
    }
1239331
protected function isFresh($destination, \DateTime $maxAge = null)
    {
        // fetch if file does not exist
        if (!file_exists($destination)) {
            return false;
        }

        // if file exists and no max-age is given, use the cached file
        if (!$maxAge instanceof \DateTime) {
            return true;
        }

        // download if ttl is passed
        $mtime = new \Datetime('@' . filemtime($destination));

        // see if cache has expired
        if ($mtime < $maxAge) {
            return false;
        }

        // check with last modified date (if available)
        if (($lastMod = $this->getLastModifiedDate()) && ($mtime < $lastMod)) {
            return false;
        }

        // all checks passed, use the cached version
        return true;
    }
486130
public function _gc($max) {
        $old = time() - $max;
        
        ORM::for_table($this->sessions_table)->raw_execute("DELETE * FROM " . $this->sessions_table . " WHERE access < :old", ['old' => $old]);
    }
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;
    }
1266457
public function gc($maxlifetime)
    {
        if (!$this->shouldGC()) return false;

        $cutOff = new \DateTime();
        $cutOff->modify('-' . $maxlifetime . ' seconds');

        try {
            $sessionSQL = sprintf(
                'delete from `%s`.`%s` where `activity` <= ?',
                $this->database,
                $this->table
            );

            $statement = $this->databaseResource->prepare($sessionSQL);

            if (empty($statement)) {
                throw new \Exception("Could not prepare session gc statement.");
            }

            $cutOffTimestamp = $cutOff->format('Y-m-d H:i:s');
            $statement->bind_param('s', $cutOffTimestamp);

            $statement->execute();

            $statement->close();

            return true;
        } catch (\Exception $exception) {
            // Log and return false
        }

        return false;
    }
891264
public function gc($max)
    {
        // delete sessions older than max TTL
        $ttl = time() - $max;

        return $this->app['db']
            ->delete(self::TABLENAME)
            ->where('access', $ttl, '<')
            ->execute() instanceof PDOStatement;
    }
235763
public function gc($maxLifetime)
    {
        //iteracja po plikach sesyjnych
        foreach (glob($this->_namespace . '*') as $sessionFile) {
            //próba określenia daty pliku
            try {
                $fileTime = filemtime($sessionFile);
            } catch (\Exception $e) {
                //plik już skasowany
                continue;
            }
            //sprawdzenie czy plik jest stary
            if ($fileTime > (time() - $maxLifetime)) {
                //nie jest
                continue;
            }
            //próba usunięcia pliku
            try {
                unlink($sessionFile);
            } catch (\Exception $e) {
                //nie udało się usunąć (usunięty przez inny proces)
            }
        }
        return true;
    }