Trim the monitored job list.

@return void
9793
public function trimMonitoredJobs()
    {
        $this->connection()->zremrangebyscore(
            'monitored_jobs', Chronos::now()->subMinutes($this->monitoredJobExpires)->getTimestamp() * -1, '+inf'
        );
    }
206754
protected function cleanup()
    {
        if ($this->resource) {
            proc_terminate($this->resource);
        }

        if (is_resource($this->handle)) {
            fclose($this->handle);
        }

        $this->handle   = null;
        $this->resource = null;
    }
1006227
public function removeAll()
    {
        $this->initializeOnDemand();

        if ($this->configMapper->truncate()) {
            $this->arrayConfig->clear();
            return true;

        } else {
            return false;
        }
    }
685743
public void trim()
	{
		List<byte[]> chunkList = mChunkList;
		while (chunkList.size() - 1 > mCurrentChunkIndex)
		{
			chunkList.remove(chunkList.size() - 1);
		}
	}
1077046
protected function cleanup()
    {
        $this->_stmt->closeCursor();

        $this->_stmt          = null;
        $this->_rsm           = null;
        $this->_cache         = array();
        $this->_metadataCache = array();
    }
1125523
private function clean()
    {
        $this->mode       = null;
        $this->source     = null;
        $this->filters    = [];
        $this->targetSize = [];
    }
488285
public function clean()
    {
        $jobFiles = glob($this->getLocation() . '*.js');
        foreach ($jobFiles as $file) {
            unlink($file);
        }
    }
1171819
public function down()
    {
        $adminRole = RoleProxy::where(['name' => 'admin'])->first();

        if ($adminRole) {
            $admins = UserProxy::where(['type' => UserType::ADMIN])->get();
            $admins->each->removeRole($adminRole);
        }

        ResourcePermissions::deletePermissionsForResource($this->resources);

        $adminRole->delete();
    }
14374
public function flush()
    {
        //todo bugfix batch record
        foreach ($this->deferLogs as $k => $deferLog) {
            $this->record($deferLog['message'], $deferLog['context'], $deferLog['level'], $deferLog['role']);
            $this->removeDeferLog($k);
        }
    }
730944
public function whitelist() {
		if ($this->params['remove']) {
			$this->Maintenance->clearWhitelist();
		}

		$ips = $this->args;
		if (!empty($ips)) {
			foreach ($ips as $ip) {
				if (!Validation::ip($ip)) {
					$this->abort($ip . ' is not a valid IP address.');
				}
			}
			if ($this->params['remove']) {
				$this->Maintenance->clearWhitelist($ips);
			} else {
				$this->Maintenance->whitelist($ips, $this->params['debug']);
			}
			$this->out('Done!', 2);
		}

		$this->out('Current whitelist:');
		$ips = $this->Maintenance->whitelist();
		if (!$ips) {
			$this->out('n/a');
		} else {
			$this->out($ips);
		}
	}
967706
private void trim() {

        // Trim
        while (values.size() > limit.getMaxEntries()) {
            values.removeLast();
        }

        // Trim according to duration
        if (limit.getMaxDuration() > 0 && !values.isEmpty()) {
            long duration = limit.getMaxDuration();
            long start = values.getFirst().getTimestamp();
            while (start - values.getLast().getTimestamp() > duration) {
                values.removeLast();
            }
        }
    }
230010
public function teardown() {
        $this->setStatus(JobStatus::COMPLETE);
        $this->duration = microtime(true) - $this->startTime;
    }
1315940
public function clear() {
        global $DB, $USER;

        \core_analytics\manager::check_can_manage_models();

        // Delete current model version stored stuff.
        $predictor = $this->get_predictions_processor(false);
        if ($predictor->is_ready() !== true) {
            $predictorname = \core_analytics\manager::get_predictions_processor_name($predictor);
            debugging('Prediction processor ' . $predictorname . ' is not ready to be used. Model ' .
                $this->model->id . ' could not be cleared.');
        } else {
            $predictor->clear_model($this->get_unique_id(), $this->get_output_dir());
        }

        $predictionids = $DB->get_fieldset_select('analytics_predictions', 'id', 'modelid = :modelid',
            array('modelid' => $this->get_id()));
        if ($predictionids) {
            list($sql, $params) = $DB->get_in_or_equal($predictionids);
            $DB->delete_records_select('analytics_prediction_actions', "predictionid $sql", $params);
        }

        $DB->delete_records('analytics_predictions', array('modelid' => $this->model->id));
        $DB->delete_records('analytics_predict_samples', array('modelid' => $this->model->id));
        $DB->delete_records('analytics_train_samples', array('modelid' => $this->model->id));
        $DB->delete_records('analytics_used_files', array('modelid' => $this->model->id));
        $DB->delete_records('analytics_used_analysables', array('modelid' => $this->model->id));

        // Purge all generated files.
        \core_analytics\dataset_manager::clear_model_files($this->model->id);

        // We don't expect people to clear models regularly and the cost of filling the cache is
        // 1 db read per context.
        $this->purge_insights_cache();

        if (!$this->is_static()) {
            $this->model->trained = 0;
        }

        $this->model->timemodified = time();
        $this->model->usermodified = $USER->id;
        $DB->update_record('analytics_models', $this->model);
    }
252671
public function cleanup() {
    $this->say("Removing deprecated files and directories...");
    $this->taskFilesystemStack()
      ->remove([
        "build",
        "docroot/sites/default/settings/apcu_fix.yml",
        "docroot/sites/default/settings/base.settings.php",
        "docroot/sites/default/settings/blt.settings.php",
        "docroot/sites/default/settings/cache.settings.php",
        "docroot/sites/default/settings/filesystem.settings.php",
        "docroot/sites/default/settings/logging.settings.php",
        "docroot/sites/default/settings/travis.settings.php",
        "docroot/sites/default/settings/pipelines.settings.php",
        "docroot/sites/default/settings/tugboat.settings.php",
        "docroot/sites/settings/global.settings.default.php",
        "tests/phpunit/blt",
        "tests/phpunit/Bolt",
        "scripts/blt",
        "scripts/drupal",
        "scripts/drupal-vm",
        "scripts/git-hooks",
        "scripts/release-notes",
        "scripts/tugboat",
        "blt.sh",
        "project.yml",
        "project.local.yml",
        "example.project.local.yml",
        "readme/acsf-setup.md",
        "readme/architecture.md",
        "readme/best-practices.md",
        "readme/deploy.md",
        "readme/dev-workflow.md",
        "readme/features-workflow.md",
        "readme/local-development.md",
        "readme/onboarding.md",
        "readme/project-tasks.md",
        "readme/release-process.md",
        "readme/repo-architecture.md",
        "readme/views.md",
        "drush/policy.drush.inc",
      ])
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->run();
  }
543009
public function delete() {
        global $DB;

        \core_analytics\manager::check_can_manage_models();

        $this->clear();

        // Method self::clear is already clearing the current model version.
        $predictor = $this->get_predictions_processor(false);
        if ($predictor->is_ready() !== true) {
            $predictorname = \core_analytics\manager::get_predictions_processor_name($predictor);
            debugging('Prediction processor ' . $predictorname . ' is not ready to be used. Model ' .
                $this->model->id . ' could not be deleted.');
        } else {
            $predictor->delete_output_dir($this->get_output_dir(array(), true));
        }

        $DB->delete_records('analytics_models', array('id' => $this->model->id));
        $DB->delete_records('analytics_models_log', array('modelid' => $this->model->id));
    }
260730
public function finish(): void
    {
        foreach ($this->drivers as $name => $class) {
            $class->finish();
            unset($this->drivers[$name]);
        }

        $this->drivers = [];
    }
975288
def clear_jobs(self, recursive=True):
        
        if recursive:
            self._scatter_link.clear_jobs(recursive)
        self.jobs.clear()