1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-01 01:18:22 +01:00
phorge-phorge/src/applications/herald/garbagecollector/HeraldTranscriptGarbageCollector.php
epriestley 56d44f1503 Modularize the Garbage Collector
Summary:
The GC is a big block of hard-coded application GCs right now. Among other things, this means third parties can't tap into the infrastructure.

Modularize it into `GarbageCollector` classes. This implements only one to prove the new stuff works; I'll followup with the rest in the next diff or few depending on how much mess I run into.

Test Plan: Used `bin/phd debug garbage` to run the collector in debug mode, observed reasonable output and behavior.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7970
2014-01-15 10:02:24 -08:00

31 lines
751 B
PHP

<?php
final class HeraldTranscriptGarbageCollector
extends PhabricatorGarbageCollector {
public function collectGarbage() {
$ttl = PhabricatorEnv::getEnvConfig('gcdaemon.ttl.herald-transcripts');
if ($ttl <= 0) {
return false;
}
$table = new HeraldTranscript();
$conn_w = $table->establishConnection('w');
queryfx(
$conn_w,
'UPDATE %T SET
objectTranscript = "",
ruleTranscripts = "",
conditionTranscripts = "",
applyTranscripts = "",
garbageCollected = 1
WHERE garbageCollected = 0 AND `time` < %d
LIMIT 100',
$table->getTableName(),
time() - $ttl);
return ($conn_w->getAffectedRows() == 100);
}
}