@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Garbage collect TTL'd cache entries from the general cache

Summary: We currently garbage collect general cache entries after a set period of time (30 days by default), but the recent changes to DarkConsole have left us writing a lot of large, short-TTL data to the cache. In addition to a maximum age, GC cache entires after they TTL out.

Test Plan: Ran GC daemon, saw TTL'd entries get collected. Inserted a TTL'd entry, saw it get collected by GC. Saw non-ttl'd entries not get collected.

Reviewers: chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D4990

+25
+2
resources/sql/patches/20130217.cachettl.sql
··· 1 + ALTER TABLE {$NAMESPACE}_cache.cache_general 2 + ADD KEY `key_ttl` (cacheExpires);
+1
src/__phutil_library_map__.php
··· 2912 2912 2 => 'PhabricatorPolicyInterface', 2913 2913 3 => 'PhabricatorSubscribableInterface', 2914 2914 4 => 'PhabricatorTokenReceiverInterface', 2915 + 5 => 'PhabricatorApplicationTransactionInterface', 2915 2916 ), 2916 2917 'PholioMockCommentController' => 'PholioController', 2917 2918 'PholioMockEditController' => 'PholioController',
+18
src/infrastructure/daemon/PhabricatorGarbageCollectorDaemon.php
··· 15 15 $n_parse = $this->collectParseCaches(); 16 16 $n_markup = $this->collectMarkupCaches(); 17 17 $n_tasks = $this->collectArchivedTasks(); 18 + $n_cache_ttl = $this->collectGeneralCacheTTL(); 18 19 $n_cache = $this->collectGeneralCaches(); 19 20 20 21 $collected = array( ··· 23 24 'Differential Parse Cache' => $n_parse, 24 25 'Markup Cache' => $n_markup, 25 26 'Archived Tasks' => $n_tasks, 27 + 'General Cache TTL' => $n_cache_ttl, 26 28 'General Cache Entries' => $n_cache, 27 29 ); 28 30 $collected = array_filter($collected); ··· 169 171 } 170 172 171 173 174 + private function collectGeneralCacheTTL() { 175 + $cache = new PhabricatorKeyValueDatabaseCache(); 176 + $conn_w = $cache->establishConnection('w'); 177 + 178 + queryfx( 179 + $conn_w, 180 + 'DELETE FROM %T WHERE cacheExpires < %d 181 + ORDER BY cacheExpires ASC LIMIT 100', 182 + $cache->getTableName(), 183 + time()); 184 + 185 + return $conn_w->getAffectedRows(); 186 + } 187 + 188 + 172 189 private function collectGeneralCaches() { 173 190 $key = 'gcdaemon.ttl.general-cache'; 174 191 $ttl = PhabricatorEnv::getEnvConfig($key); ··· 188 205 189 206 return $conn_w->getAffectedRows(); 190 207 } 208 + 191 209 192 210 }
+4
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1125 1125 'type' => 'sql', 1126 1126 'name' => $this->getPatchPath('20130214.token.sql'), 1127 1127 ), 1128 + '20130217.cachettl.sql' => array( 1129 + 'type' => 'sql', 1130 + 'name' => $this->getPatchPath('20130217.cachettl.sql'), 1131 + ), 1128 1132 ); 1129 1133 } 1130 1134