Differential D14219 Diff 34352 src/applications/cache/garbagecollector/PhabricatorCacheTTLGarbageCollector.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/cache/garbagecollector/PhabricatorCacheTTLGarbageCollector.php
| <?php | <?php | ||||
| final class PhabricatorCacheTTLGarbageCollector | final class PhabricatorCacheTTLGarbageCollector | ||||
| extends PhabricatorGarbageCollector { | extends PhabricatorGarbageCollector { | ||||
| const COLLECTORCONST = 'cache.general.ttl'; | const COLLECTORCONST = 'cache.general.ttl'; | ||||
| public function getCollectorName() { | public function getCollectorName() { | ||||
| return pht('General Cache (TTL)'); | return pht('General Cache (TTL)'); | ||||
| } | } | ||||
| public function hasAutomaticPolicy() { | public function hasAutomaticPolicy() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function collectGarbage() { | protected function collectGarbage() { | ||||
| $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 cacheExpires < %d | 'DELETE FROM %T WHERE cacheExpires < %d | ||||
| ORDER BY cacheExpires ASC LIMIT 100', | ORDER BY cacheExpires ASC LIMIT 100', | ||||
| $cache->getTableName(), | $cache->getTableName(), | ||||
| time()); | PhabricatorTime::getNow()); | ||||
| return ($conn_w->getAffectedRows() == 100); | return ($conn_w->getAffectedRows() == 100); | ||||
| } | } | ||||
| } | } | ||||