Differential D14219 Diff 34352 src/applications/cache/garbagecollector/PhabricatorCacheGeneralGarbageCollector.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/cache/garbagecollector/PhabricatorCacheGeneralGarbageCollector.php
| <?php | <?php | ||||
| final class PhabricatorCacheGeneralGarbageCollector | final class PhabricatorCacheGeneralGarbageCollector | ||||
| extends PhabricatorGarbageCollector { | extends PhabricatorGarbageCollector { | ||||
| const COLLECTORCONST = 'cache.general'; | const COLLECTORCONST = 'cache.general'; | ||||
| public function getCollectorName() { | public function getCollectorName() { | ||||
| return pht('General Cache'); | return pht('General Cache'); | ||||
| } | } | ||||
| public function getDefaultRetentionPolicy() { | public function getDefaultRetentionPolicy() { | ||||
| return phutil_units('30 days in seconds'); | return phutil_units('30 days in seconds'); | ||||
| } | } | ||||
| public function collectGarbage() { | protected function collectGarbage() { | ||||
| $key = 'gcdaemon.ttl.general-cache'; | |||||
| $ttl = PhabricatorEnv::getEnvConfig($key); | |||||
| if ($ttl <= 0) { | |||||
| return false; | |||||
| } | |||||
| $cache = new PhabricatorKeyValueDatabaseCache(); | $cache = new PhabricatorKeyValueDatabaseCache(); | ||||
| $conn_w = $cache->establishConnection('w'); | $conn_w = $cache->establishConnection('w'); | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'DELETE FROM %T WHERE cacheCreated < %d | 'DELETE FROM %T WHERE cacheCreated < %d | ||||
| ORDER BY cacheCreated ASC LIMIT 100', | ORDER BY cacheCreated ASC LIMIT 100', | ||||
| $cache->getTableName(), | $cache->getTableName(), | ||||
| time() - $ttl); | $this->getGarbageEpoch()); | ||||
| return ($conn_w->getAffectedRows() == 100); | return ($conn_w->getAffectedRows() == 100); | ||||
| } | } | ||||
| } | } | ||||