diff --git a/resources/sql/patches/20130217.cachettl.sql b/resources/sql/patches/20130217.cachettl.sql new file mode 100644 index 0000000000..2bb3beb11b --- /dev/null +++ b/resources/sql/patches/20130217.cachettl.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_cache.cache_general + ADD KEY `key_ttl` (cacheExpires); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index b4aad3e01e..9199cfffe3 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2912,6 +2912,7 @@ phutil_register_library_map(array( 2 => 'PhabricatorPolicyInterface', 3 => 'PhabricatorSubscribableInterface', 4 => 'PhabricatorTokenReceiverInterface', + 5 => 'PhabricatorApplicationTransactionInterface', ), 'PholioMockCommentController' => 'PholioController', 'PholioMockEditController' => 'PholioController', diff --git a/src/infrastructure/daemon/PhabricatorGarbageCollectorDaemon.php b/src/infrastructure/daemon/PhabricatorGarbageCollectorDaemon.php index a626eaee69..f4f678b14c 100644 --- a/src/infrastructure/daemon/PhabricatorGarbageCollectorDaemon.php +++ b/src/infrastructure/daemon/PhabricatorGarbageCollectorDaemon.php @@ -15,6 +15,7 @@ final class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon { $n_parse = $this->collectParseCaches(); $n_markup = $this->collectMarkupCaches(); $n_tasks = $this->collectArchivedTasks(); + $n_cache_ttl = $this->collectGeneralCacheTTL(); $n_cache = $this->collectGeneralCaches(); $collected = array( @@ -23,6 +24,7 @@ final class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon { 'Differential Parse Cache' => $n_parse, 'Markup Cache' => $n_markup, 'Archived Tasks' => $n_tasks, + 'General Cache TTL' => $n_cache_ttl, 'General Cache Entries' => $n_cache, ); $collected = array_filter($collected); @@ -169,6 +171,21 @@ final class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon { } + private function collectGeneralCacheTTL() { + $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(); + } + + private function collectGeneralCaches() { $key = 'gcdaemon.ttl.general-cache'; $ttl = PhabricatorEnv::getEnvConfig($key); @@ -189,4 +206,5 @@ final class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon { return $conn_w->getAffectedRows(); } + } diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index 3008ee4472..e67d1375fc 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -1125,6 +1125,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'sql', 'name' => $this->getPatchPath('20130214.token.sql'), ), + '20130217.cachettl.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('20130217.cachettl.sql'), + ), ); }