Complete modularization of the GC daemon
Summary: This modularizes the rest of the GC submethods. Turned out there was nothing tricky. Test Plan: Ran `bin/phd debug garbage` and got reasonable looking behavior and output. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7971
This commit is contained in:
26
src/applications/cache/garbagecollector/PhabricatorCacheGeneralGarbageCollector.php
vendored
Normal file
26
src/applications/cache/garbagecollector/PhabricatorCacheGeneralGarbageCollector.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorCacheGeneralGarbageCollector
|
||||
extends PhabricatorGarbageCollector {
|
||||
|
||||
public function collectGarbage() {
|
||||
$key = 'gcdaemon.ttl.general-cache';
|
||||
$ttl = PhabricatorEnv::getEnvConfig($key);
|
||||
if ($ttl <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cache = new PhabricatorKeyValueDatabaseCache();
|
||||
$conn_w = $cache->establishConnection('w');
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'DELETE FROM %T WHERE cacheCreated < %d
|
||||
ORDER BY cacheCreated ASC LIMIT 100',
|
||||
$cache->getTableName(),
|
||||
time() - $ttl);
|
||||
|
||||
return ($conn_w->getAffectedRows() == 100);
|
||||
}
|
||||
|
||||
}
|
||||
25
src/applications/cache/garbagecollector/PhabricatorCacheMarkupGarbageCollector.php
vendored
Normal file
25
src/applications/cache/garbagecollector/PhabricatorCacheMarkupGarbageCollector.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorCacheMarkupGarbageCollector
|
||||
extends PhabricatorGarbageCollector {
|
||||
|
||||
public function collectGarbage() {
|
||||
$key = 'gcdaemon.ttl.markup-cache';
|
||||
$ttl = PhabricatorEnv::getEnvConfig($key);
|
||||
if ($ttl <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$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() == 100);
|
||||
}
|
||||
|
||||
}
|
||||
20
src/applications/cache/garbagecollector/PhabricatorCacheTTLGarbageCollector.php
vendored
Normal file
20
src/applications/cache/garbagecollector/PhabricatorCacheTTLGarbageCollector.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorCacheTTLGarbageCollector
|
||||
extends PhabricatorGarbageCollector {
|
||||
|
||||
public function collectGarbage() {
|
||||
$cache = new PhabricatorKeyValueDatabaseCache();
|
||||
$conn_w = $cache->establishConnection('w');
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'DELETE FROM %T WHERE cacheExpires < %d
|
||||
ORDER BY cacheExpires ASC LIMIT 100',
|
||||
$cache->getTableName(),
|
||||
time());
|
||||
|
||||
return ($conn_w->getAffectedRows() == 100);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user