Differential D14219 Diff 34352 src/applications/daemon/garbagecollector/PhabricatorDaemonLogEventGarbageCollector.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/daemon/garbagecollector/PhabricatorDaemonLogEventGarbageCollector.php
<?php | <?php | ||||
final class PhabricatorDaemonLogEventGarbageCollector | final class PhabricatorDaemonLogEventGarbageCollector | ||||
extends PhabricatorGarbageCollector { | extends PhabricatorGarbageCollector { | ||||
const COLLECTORCONST = 'daemon.processes'; | const COLLECTORCONST = 'daemon.processes'; | ||||
public function getCollectorName() { | public function getCollectorName() { | ||||
return pht('Daemon Processes'); | return pht('Daemon Processes'); | ||||
} | } | ||||
public function getDefaultRetentionPolicy() { | public function getDefaultRetentionPolicy() { | ||||
return phutil_units('7 days in seconds'); | return phutil_units('7 days in seconds'); | ||||
} | } | ||||
public function collectGarbage() { | protected function collectGarbage() { | ||||
$ttl = PhabricatorEnv::getEnvConfig('gcdaemon.ttl.daemon-logs'); | |||||
if ($ttl <= 0) { | |||||
return false; | |||||
} | |||||
$table = new PhabricatorDaemonLogEvent(); | $table = new PhabricatorDaemonLogEvent(); | ||||
$conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
queryfx( | queryfx( | ||||
$conn_w, | $conn_w, | ||||
'DELETE FROM %T WHERE epoch < %d LIMIT 100', | 'DELETE FROM %T WHERE epoch < %d LIMIT 100', | ||||
$table->getTableName(), | $table->getTableName(), | ||||
time() - $ttl); | $this->getGarbageEpoch()); | ||||
return ($conn_w->getAffectedRows() == 100); | return ($conn_w->getAffectedRows() == 100); | ||||
} | } | ||||
} | } |