mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
Add markup cache collection to the GC daemon
Summary: Allow the GC daemon to collect the new markup cache. Test Plan: Ran gc daemon in "debug" mode, saw it collect cache entries. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D2947
This commit is contained in:
parent
5d8b75b4da
commit
fcd04708d2
2 changed files with 25 additions and 6 deletions
|
@ -1007,6 +1007,7 @@ return array(
|
|||
'gcdaemon.ttl.herald-transcripts' => 30 * (24 * 60 * 60),
|
||||
'gcdaemon.ttl.daemon-logs' => 7 * (24 * 60 * 60),
|
||||
'gcdaemon.ttl.differential-parse-cache' => 14 * (24 * 60 * 60),
|
||||
'gcdaemon.ttl.markup-cache' => 30 * (24 * 60 * 60),
|
||||
|
||||
|
||||
// -- Feed ------------------------------------------------------------------ //
|
||||
|
|
|
@ -46,7 +46,7 @@ final class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon {
|
|||
|
||||
if ($now < $start || $now > ($start + $run_for)) {
|
||||
if ($just_ran) {
|
||||
echo "Stopped garbage collector.\n";
|
||||
$this->log("Stopped garbage collector.");
|
||||
$just_ran = false;
|
||||
}
|
||||
// The configuration says we can't collect garbage right now, so
|
||||
|
@ -56,27 +56,26 @@ final class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon {
|
|||
}
|
||||
|
||||
if (!$just_ran) {
|
||||
echo "Started garbage collector.\n";
|
||||
$this->log("Started garbage collector.");
|
||||
$just_ran = true;
|
||||
}
|
||||
|
||||
$n_herald = $this->collectHeraldTranscripts();
|
||||
$n_daemon = $this->collectDaemonLogs();
|
||||
$n_parse = $this->collectParseCaches();
|
||||
$n_markup = $this->collectMarkupCaches();
|
||||
|
||||
$collected = array(
|
||||
'Herald Transcript' => $n_herald,
|
||||
'Daemon Log' => $n_daemon,
|
||||
'Differential Parse Cache' => $n_parse,
|
||||
'Markup Cache' => $n_markup,
|
||||
);
|
||||
$collected = array_filter($collected);
|
||||
|
||||
foreach ($collected as $thing => $count) {
|
||||
if ($thing == 'Daemon Log' && !$this->getTraceMode()) {
|
||||
continue;
|
||||
}
|
||||
$count = number_format($count);
|
||||
echo "Garbage collected {$count} '{$thing}' objects.\n";
|
||||
$this->log("Garbage collected {$count} '{$thing}' objects.");
|
||||
}
|
||||
|
||||
$total = array_sum($collected);
|
||||
|
@ -154,4 +153,23 @@ final class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon {
|
|||
return $conn_w->getAffectedRows();
|
||||
}
|
||||
|
||||
private function collectMarkupCaches() {
|
||||
$key = 'gcdaemon.ttl.markup-cache';
|
||||
$ttl = PhabricatorEnv::getEnvConfig($key);
|
||||
if ($ttl <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$table = new PhabricatorMarkupCache();
|
||||
$conn_w = $table->establishConnection('w');
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'DELETE FROM %T WHERE dateCreated < %d LIMIT 100',
|
||||
$table->getTableName(),
|
||||
time() - $ttl);
|
||||
|
||||
return $conn_w->getAffectedRows();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue