Iterates over all existing sessions and removes their data if the inactivity
timeout was reached.

@return integer The number of outdated entries removed
@throws \Neos\Cache\Exception
@throws NotSupportedByBackendException
@api
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;
    }
443587
public function deleteOutdated(): bool
    {
        //TODO: check the need to call
        clearstatcache();
        
        $dh = @opendir($this->cacheDir);
        if (false === $dh) {
            return false;
        }
        
        while (false !== ($entry = readdir($dh))) {
            $filePath = $this->cacheDir . '/' . $entry;
            
            //exclude '.', '..', '.htaccess'
            if (!is_file($filePath) || 0 === strpos($entry, '.')) {
                continue;
            }
            
            try {
                $packet = $this->getPacketFromFile($filePath);
                if ($packet->outdated()) {
                    unlink($filePath);
                }
            } catch (BadPacketException $e) {
                unlink($filePath);
            }
        }
        
        closedir($dh);
        
        return true;
    }
837813
public function delete()
    {
        $data = $this->getData();
        if (isset($this->currentId))
        {
            unset($data[$this->currentKey]);
        }
        else
        {
            $this->pending();
            $old  = $data;
            $data = array_diff_key($old, $this->data);
        }
        $this->data = array_values($data);

        return Helpers\Data::table($this->name)->put($this->data) ? true : false;
    }
198060
public function clear()
    {
        if (isset($this->config[ 'dbIndex' ])) {
            return $this->redis->flushDB();
        } else {
            return $this->redis->flushAll();
        }
    }
547781
public function deleteExpired()
    {
        // General expirations. Maximum limiter is 1m.
        $oldest = new \DateTime('-1 month -1 day');
        $q      = $this->getEntityManager()->getConnection()->createQueryBuilder();
        $q->delete(MAUTIC_TABLE_PREFIX.$this->getTableName());
        $q->where(
            $q->expr()->lt('date_added', 'FROM_UNIXTIME(:oldest)')
        );
        $q->setParameter('oldest', (int) $oldest->getTimestamp());
        $q->execute();
    }
841526
public static function clearSession() {
    $user = self::$currentUser;
    self::$currentUser = null;
    if (isset(self::$serverTimezone)) {
      date_default_timezone_set(self::$serverTimezone);
    }
    if ($user) {
      $user->updateDataProtection();
    }
  }
757846
public function removesessionAction()
    {
        $success = false;
        $request = $this->getEvent()->getRequest();
        if ($request instanceof Request && $request->isPost()) {
            $containerName = $request->getPost('containerName', 'Default');
            $keysession = $request->getPost('keysession', '');

            $success = $this->sessionManager
                            ->sessionSetting($containerName, $keysession);
        }

        return new JsonModel([
            'success' => $success,
        ]);
    }
522882
protected function handleDELETE()
    {
        /** @var BaseSystemModel $modelClass */
        $modelClass = static::$model;
        $options = $this->request->getParameters();

        if (!empty($this->resource)) {
            return $modelClass::deleteById($this->resource, $options);
        }

        if (!empty($ids = array_get($options, ApiOptions::IDS))) {
            $result = $modelClass::deleteByIds($ids, $options);
        } else {
            $records = ResourcesWrapper::unwrapResources($this->getPayloadData());
            if (!empty($records)) {
                $result = $modelClass::bulkDelete($records, $options);
            } else {
                $filter = array_get($options, ApiOptions::FILTER);
                if (!empty($filter)) {
                    $params = array_get($options, ApiOptions::PARAMS, []);
                    $result = $modelClass::deleteByFilter($filter, $params, $options);
                } else {
                    if (!array_get_bool($options, ApiOptions::FORCE)) {
                        throw new BadRequestException('No filter or records given for delete request.');
                    }

                    return $modelClass::truncate($options);
                }
            }
        }

        $asList = $this->request->getParameterAsBool(ApiOptions::AS_LIST);
        $idField = $this->request->getParameter(ApiOptions::ID_FIELD, static::getResourceIdentifier());
        $result = ResourcesWrapper::cleanResources($result, $asList, $idField, ApiOptions::FIELDS_ALL);

        return $result;
    }
890069
public function delete() {
    if ($this->isNew()) {
      throw new \Exception('ID is not setted for Delete');
    }

    $this->db()->delete($this->table, $this->identifier());
    $this->isDeleted = TRUE;

    return $this;
  }
31324
public function clearExpired()
    {
        if ($this->options['cache']) {
            $keys = Ioc::cache($this->options['name'])->clearExpired();
        }
        
        return ErrorInfo::success($this->options['name'] . ' clear success: ' . $count . ' items');
    }
30651
public function purge() {
        if (class_exists('APCUIterator', false)) {
            $iterator = new APCUIterator('#^' . preg_quote($this->cacheprefix, '#') . '#');
        } else {
            $iterator = new APCIterator('user', '#^' . preg_quote($this->cacheprefix, '#') . '#');
        }
        return apcu_delete($iterator);
    }
670527
public function delete(): int
    {
        try {
            $query = (clone $this)->setDelete()->apply($this->database->getTablePrefixer());
            $compiled = $this->database->getGrammar()->compileDelete($query);
            return $this->database->delete($compiled->getSQL(), $compiled->getBindings());
        } catch (\Throwable $exception) {
            return $this->handleException($exception);
        }
    }
208868
public function clear():bool
    {
        if (true === $this->isStarted()) {
            session_unset();
            $this->setToDefault();
            session_regenerate_id(true);
            return (empty($_SESSION)? true : false);
        }
        throw new Server500(new \ArrayObject(array("explain" => "Cannot clear the session when is not started",
            "solution" => "Please start a session instance before clear it")));
    }
1350897
public function eraseExpired() {
    $cacheData = $this->_loadCache();
    if (true === is_array($cacheData)) {
      $counter = 0;
      foreach ($cacheData as $key => $entry) {
        if (true === $this->_checkExpired($entry['time'], $entry['expire'])) {
          unset($cacheData[$key]);
          $counter++;
        }
      }
      if ($counter > 0) {
        $cacheData = json_encode($cacheData);
        file_put_contents($this->getCacheDir(), $cacheData);
      }
      return $counter;
    }
  }
390917
public function clear()
    {
        $purged = $this->writeStorage->clear();

        if ($this->bigStorage) {
            $this->bigStorage->clear();
        }

        $this->entryCache = [];

        return $purged;
    }
585444
public static function unstaged()
	{
		$available = static::available();
		
		foreach( $available as $key => $migrations )
		{
			foreach( $migrations as $time => $migration )
			{
				if ( $time <= static::$config->get( $key.'.revision', 0 ) )
				{
					unset( $available[$key][$time] );
				}
			}
		}
		
		return $available;
	}
28172
@Override
    @Scheduled(fixedRate = REAP_INTERVAL)
    public void removeExpired() {
        final Set<String> reapable = sessions.entrySet().stream()
                .filter(e -> e.getValue().getExpires().isPresent())
                .filter(e -> e.getValue().getExpires().get().isBefore(now()))
                .map(Map.Entry::getKey).collect(toSet());
        reapable.forEach(key -> {
            final FedoraSession s = sessions.get(key);
            if (s != null) {
                try {
                    s.expire();
                } catch (final RepositoryRuntimeException e) {
                    LOGGER.error("Got exception rolling back expired session {}: {}", s, e.getMessage());
                }
            }
            sessions.remove(key);
        });
    }