mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Modularize "bin/cache" purgers
Summary: Ref T12859. This is an older command with a lot of hard-coded flags. Modularize cache purging in a modern way so it can be extended. Test Plan: Ran `bin/cache purge --trace` with various valid and invalid flags. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12859 Differential Revision: https://secure.phabricator.com/D18146
This commit is contained in:
parent
519bec3e6f
commit
bd3f441098
7 changed files with 161 additions and 93 deletions
|
@ -2171,6 +2171,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCacheManagementPurgeWorkflow' => 'applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php',
|
'PhabricatorCacheManagementPurgeWorkflow' => 'applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php',
|
||||||
'PhabricatorCacheManagementWorkflow' => 'applications/cache/management/PhabricatorCacheManagementWorkflow.php',
|
'PhabricatorCacheManagementWorkflow' => 'applications/cache/management/PhabricatorCacheManagementWorkflow.php',
|
||||||
'PhabricatorCacheMarkupGarbageCollector' => 'applications/cache/garbagecollector/PhabricatorCacheMarkupGarbageCollector.php',
|
'PhabricatorCacheMarkupGarbageCollector' => 'applications/cache/garbagecollector/PhabricatorCacheMarkupGarbageCollector.php',
|
||||||
|
'PhabricatorCachePurger' => 'applications/cache/purger/PhabricatorCachePurger.php',
|
||||||
'PhabricatorCacheSchemaSpec' => 'applications/cache/storage/PhabricatorCacheSchemaSpec.php',
|
'PhabricatorCacheSchemaSpec' => 'applications/cache/storage/PhabricatorCacheSchemaSpec.php',
|
||||||
'PhabricatorCacheSetupCheck' => 'applications/config/check/PhabricatorCacheSetupCheck.php',
|
'PhabricatorCacheSetupCheck' => 'applications/config/check/PhabricatorCacheSetupCheck.php',
|
||||||
'PhabricatorCacheSpec' => 'applications/cache/spec/PhabricatorCacheSpec.php',
|
'PhabricatorCacheSpec' => 'applications/cache/spec/PhabricatorCacheSpec.php',
|
||||||
|
@ -2320,6 +2321,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCelerityApplication' => 'applications/celerity/application/PhabricatorCelerityApplication.php',
|
'PhabricatorCelerityApplication' => 'applications/celerity/application/PhabricatorCelerityApplication.php',
|
||||||
'PhabricatorCelerityTestCase' => '__tests__/PhabricatorCelerityTestCase.php',
|
'PhabricatorCelerityTestCase' => '__tests__/PhabricatorCelerityTestCase.php',
|
||||||
'PhabricatorChangeParserTestCase' => 'applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php',
|
'PhabricatorChangeParserTestCase' => 'applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php',
|
||||||
|
'PhabricatorChangesetCachePurger' => 'applications/cache/purger/PhabricatorChangesetCachePurger.php',
|
||||||
'PhabricatorChangesetResponse' => 'infrastructure/diff/PhabricatorChangesetResponse.php',
|
'PhabricatorChangesetResponse' => 'infrastructure/diff/PhabricatorChangesetResponse.php',
|
||||||
'PhabricatorChatLogApplication' => 'applications/chatlog/application/PhabricatorChatLogApplication.php',
|
'PhabricatorChatLogApplication' => 'applications/chatlog/application/PhabricatorChatLogApplication.php',
|
||||||
'PhabricatorChatLogChannel' => 'applications/chatlog/storage/PhabricatorChatLogChannel.php',
|
'PhabricatorChatLogChannel' => 'applications/chatlog/storage/PhabricatorChatLogChannel.php',
|
||||||
|
@ -2930,6 +2932,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorGarbageCollectorManagementCollectWorkflow' => 'infrastructure/daemon/garbagecollector/management/PhabricatorGarbageCollectorManagementCollectWorkflow.php',
|
'PhabricatorGarbageCollectorManagementCollectWorkflow' => 'infrastructure/daemon/garbagecollector/management/PhabricatorGarbageCollectorManagementCollectWorkflow.php',
|
||||||
'PhabricatorGarbageCollectorManagementSetPolicyWorkflow' => 'infrastructure/daemon/garbagecollector/management/PhabricatorGarbageCollectorManagementSetPolicyWorkflow.php',
|
'PhabricatorGarbageCollectorManagementSetPolicyWorkflow' => 'infrastructure/daemon/garbagecollector/management/PhabricatorGarbageCollectorManagementSetPolicyWorkflow.php',
|
||||||
'PhabricatorGarbageCollectorManagementWorkflow' => 'infrastructure/daemon/garbagecollector/management/PhabricatorGarbageCollectorManagementWorkflow.php',
|
'PhabricatorGarbageCollectorManagementWorkflow' => 'infrastructure/daemon/garbagecollector/management/PhabricatorGarbageCollectorManagementWorkflow.php',
|
||||||
|
'PhabricatorGeneralCachePurger' => 'applications/cache/purger/PhabricatorGeneralCachePurger.php',
|
||||||
'PhabricatorGestureUIExample' => 'applications/uiexample/examples/PhabricatorGestureUIExample.php',
|
'PhabricatorGestureUIExample' => 'applications/uiexample/examples/PhabricatorGestureUIExample.php',
|
||||||
'PhabricatorGitGraphStream' => 'applications/repository/daemon/PhabricatorGitGraphStream.php',
|
'PhabricatorGitGraphStream' => 'applications/repository/daemon/PhabricatorGitGraphStream.php',
|
||||||
'PhabricatorGitHubAuthProvider' => 'applications/auth/provider/PhabricatorGitHubAuthProvider.php',
|
'PhabricatorGitHubAuthProvider' => 'applications/auth/provider/PhabricatorGitHubAuthProvider.php',
|
||||||
|
@ -3748,6 +3751,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorRegistrationProfile' => 'applications/people/storage/PhabricatorRegistrationProfile.php',
|
'PhabricatorRegistrationProfile' => 'applications/people/storage/PhabricatorRegistrationProfile.php',
|
||||||
'PhabricatorReleephApplication' => 'applications/releeph/application/PhabricatorReleephApplication.php',
|
'PhabricatorReleephApplication' => 'applications/releeph/application/PhabricatorReleephApplication.php',
|
||||||
'PhabricatorReleephApplicationConfigOptions' => 'applications/releeph/config/PhabricatorReleephApplicationConfigOptions.php',
|
'PhabricatorReleephApplicationConfigOptions' => 'applications/releeph/config/PhabricatorReleephApplicationConfigOptions.php',
|
||||||
|
'PhabricatorRemarkupCachePurger' => 'applications/cache/purger/PhabricatorRemarkupCachePurger.php',
|
||||||
'PhabricatorRemarkupControl' => 'view/form/control/PhabricatorRemarkupControl.php',
|
'PhabricatorRemarkupControl' => 'view/form/control/PhabricatorRemarkupControl.php',
|
||||||
'PhabricatorRemarkupCowsayBlockInterpreter' => 'infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php',
|
'PhabricatorRemarkupCowsayBlockInterpreter' => 'infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php',
|
||||||
'PhabricatorRemarkupCustomBlockRule' => 'infrastructure/markup/rule/PhabricatorRemarkupCustomBlockRule.php',
|
'PhabricatorRemarkupCustomBlockRule' => 'infrastructure/markup/rule/PhabricatorRemarkupCustomBlockRule.php',
|
||||||
|
@ -4202,6 +4206,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorUserBadgesCacheType' => 'applications/people/cache/PhabricatorUserBadgesCacheType.php',
|
'PhabricatorUserBadgesCacheType' => 'applications/people/cache/PhabricatorUserBadgesCacheType.php',
|
||||||
'PhabricatorUserBlurbField' => 'applications/people/customfield/PhabricatorUserBlurbField.php',
|
'PhabricatorUserBlurbField' => 'applications/people/customfield/PhabricatorUserBlurbField.php',
|
||||||
'PhabricatorUserCache' => 'applications/people/storage/PhabricatorUserCache.php',
|
'PhabricatorUserCache' => 'applications/people/storage/PhabricatorUserCache.php',
|
||||||
|
'PhabricatorUserCachePurger' => 'applications/cache/purger/PhabricatorUserCachePurger.php',
|
||||||
'PhabricatorUserCacheType' => 'applications/people/cache/PhabricatorUserCacheType.php',
|
'PhabricatorUserCacheType' => 'applications/people/cache/PhabricatorUserCacheType.php',
|
||||||
'PhabricatorUserCardView' => 'applications/people/view/PhabricatorUserCardView.php',
|
'PhabricatorUserCardView' => 'applications/people/view/PhabricatorUserCardView.php',
|
||||||
'PhabricatorUserConfigOptions' => 'applications/people/config/PhabricatorUserConfigOptions.php',
|
'PhabricatorUserConfigOptions' => 'applications/people/config/PhabricatorUserConfigOptions.php',
|
||||||
|
@ -7366,6 +7371,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCacheManagementPurgeWorkflow' => 'PhabricatorCacheManagementWorkflow',
|
'PhabricatorCacheManagementPurgeWorkflow' => 'PhabricatorCacheManagementWorkflow',
|
||||||
'PhabricatorCacheManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
'PhabricatorCacheManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
||||||
'PhabricatorCacheMarkupGarbageCollector' => 'PhabricatorGarbageCollector',
|
'PhabricatorCacheMarkupGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||||
|
'PhabricatorCachePurger' => 'Phobject',
|
||||||
'PhabricatorCacheSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
'PhabricatorCacheSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
||||||
'PhabricatorCacheSetupCheck' => 'PhabricatorSetupCheck',
|
'PhabricatorCacheSetupCheck' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorCacheSpec' => 'Phobject',
|
'PhabricatorCacheSpec' => 'Phobject',
|
||||||
|
@ -7551,6 +7557,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCelerityApplication' => 'PhabricatorApplication',
|
'PhabricatorCelerityApplication' => 'PhabricatorApplication',
|
||||||
'PhabricatorCelerityTestCase' => 'PhabricatorTestCase',
|
'PhabricatorCelerityTestCase' => 'PhabricatorTestCase',
|
||||||
'PhabricatorChangeParserTestCase' => 'PhabricatorWorkingCopyTestCase',
|
'PhabricatorChangeParserTestCase' => 'PhabricatorWorkingCopyTestCase',
|
||||||
|
'PhabricatorChangesetCachePurger' => 'PhabricatorCachePurger',
|
||||||
'PhabricatorChangesetResponse' => 'AphrontProxyResponse',
|
'PhabricatorChangesetResponse' => 'AphrontProxyResponse',
|
||||||
'PhabricatorChatLogApplication' => 'PhabricatorApplication',
|
'PhabricatorChatLogApplication' => 'PhabricatorApplication',
|
||||||
'PhabricatorChatLogChannel' => array(
|
'PhabricatorChatLogChannel' => array(
|
||||||
|
@ -8253,6 +8260,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorGarbageCollectorManagementCollectWorkflow' => 'PhabricatorGarbageCollectorManagementWorkflow',
|
'PhabricatorGarbageCollectorManagementCollectWorkflow' => 'PhabricatorGarbageCollectorManagementWorkflow',
|
||||||
'PhabricatorGarbageCollectorManagementSetPolicyWorkflow' => 'PhabricatorGarbageCollectorManagementWorkflow',
|
'PhabricatorGarbageCollectorManagementSetPolicyWorkflow' => 'PhabricatorGarbageCollectorManagementWorkflow',
|
||||||
'PhabricatorGarbageCollectorManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
'PhabricatorGarbageCollectorManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
||||||
|
'PhabricatorGeneralCachePurger' => 'PhabricatorCachePurger',
|
||||||
'PhabricatorGestureUIExample' => 'PhabricatorUIExample',
|
'PhabricatorGestureUIExample' => 'PhabricatorUIExample',
|
||||||
'PhabricatorGitGraphStream' => 'PhabricatorRepositoryGraphStream',
|
'PhabricatorGitGraphStream' => 'PhabricatorRepositoryGraphStream',
|
||||||
'PhabricatorGitHubAuthProvider' => 'PhabricatorOAuth2AuthProvider',
|
'PhabricatorGitHubAuthProvider' => 'PhabricatorOAuth2AuthProvider',
|
||||||
|
@ -9204,6 +9212,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorRegistrationProfile' => 'Phobject',
|
'PhabricatorRegistrationProfile' => 'Phobject',
|
||||||
'PhabricatorReleephApplication' => 'PhabricatorApplication',
|
'PhabricatorReleephApplication' => 'PhabricatorApplication',
|
||||||
'PhabricatorReleephApplicationConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorReleephApplicationConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
|
'PhabricatorRemarkupCachePurger' => 'PhabricatorCachePurger',
|
||||||
'PhabricatorRemarkupControl' => 'AphrontFormTextAreaControl',
|
'PhabricatorRemarkupControl' => 'AphrontFormTextAreaControl',
|
||||||
'PhabricatorRemarkupCowsayBlockInterpreter' => 'PhutilRemarkupBlockInterpreter',
|
'PhabricatorRemarkupCowsayBlockInterpreter' => 'PhutilRemarkupBlockInterpreter',
|
||||||
'PhabricatorRemarkupCustomBlockRule' => 'PhutilRemarkupBlockRule',
|
'PhabricatorRemarkupCustomBlockRule' => 'PhutilRemarkupBlockRule',
|
||||||
|
@ -9756,6 +9765,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorUserBadgesCacheType' => 'PhabricatorUserCacheType',
|
'PhabricatorUserBadgesCacheType' => 'PhabricatorUserCacheType',
|
||||||
'PhabricatorUserBlurbField' => 'PhabricatorUserCustomField',
|
'PhabricatorUserBlurbField' => 'PhabricatorUserCustomField',
|
||||||
'PhabricatorUserCache' => 'PhabricatorUserDAO',
|
'PhabricatorUserCache' => 'PhabricatorUserDAO',
|
||||||
|
'PhabricatorUserCachePurger' => 'PhabricatorCachePurger',
|
||||||
'PhabricatorUserCacheType' => 'Phobject',
|
'PhabricatorUserCacheType' => 'Phobject',
|
||||||
'PhabricatorUserCardView' => 'AphrontTagView',
|
'PhabricatorUserCardView' => 'AphrontTagView',
|
||||||
'PhabricatorUserConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorUserConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
|
|
|
@ -6,119 +6,75 @@ final class PhabricatorCacheManagementPurgeWorkflow
|
||||||
protected function didConstruct() {
|
protected function didConstruct() {
|
||||||
$this
|
$this
|
||||||
->setName('purge')
|
->setName('purge')
|
||||||
->setSynopsis(pht('Drop data from caches. APC-based caches can be '.
|
->setSynopsis(pht('Drop data from readthrough caches.'))
|
||||||
'purged from the web interface.'))
|
|
||||||
->setArguments(
|
->setArguments(
|
||||||
array(
|
array(
|
||||||
array(
|
array(
|
||||||
'name' => 'purge-all',
|
'name' => 'all',
|
||||||
'help' => pht('Purge all caches.'),
|
'help' => pht('Purge all caches.'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'purge-remarkup',
|
'name' => 'caches',
|
||||||
'help' => pht('Purge the remarkup cache.'),
|
'param' => 'keys',
|
||||||
),
|
'help' => pht('Purge a specific set of caches.'),
|
||||||
array(
|
|
||||||
'name' => 'purge-changeset',
|
|
||||||
'help' => pht('Purge the Differential changeset cache.'),
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'name' => 'purge-general',
|
|
||||||
'help' => pht('Purge the general cache.'),
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'name' => 'purge-user',
|
|
||||||
'help' => pht('Purge the user cache.'),
|
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(PhutilArgumentParser $args) {
|
public function execute(PhutilArgumentParser $args) {
|
||||||
$console = PhutilConsole::getConsole();
|
$all_purgers = PhabricatorCachePurger::getAllPurgers();
|
||||||
|
|
||||||
$purge_all = $args->getArg('purge-all');
|
$is_all = $args->getArg('all');
|
||||||
|
$key_list = $args->getArg('caches');
|
||||||
$purge = array(
|
|
||||||
'remarkup' => $purge_all || $args->getArg('purge-remarkup'),
|
|
||||||
'changeset' => $purge_all || $args->getArg('purge-changeset'),
|
|
||||||
'general' => $purge_all || $args->getArg('purge-general'),
|
|
||||||
'user' => $purge_all || $args->getArg('purge-user'),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!array_filter($purge)) {
|
|
||||||
$list = array();
|
|
||||||
foreach ($purge as $key => $ignored) {
|
|
||||||
$list[] = "'--purge-".$key."'";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($is_all && strlen($key_list)) {
|
||||||
throw new PhutilArgumentUsageException(
|
throw new PhutilArgumentUsageException(
|
||||||
pht(
|
pht(
|
||||||
"Specify which cache or caches to purge, or use '%s'. Available ".
|
'Specify either "--all" or "--caches", not both.'));
|
||||||
"caches are: %s. Use '%s' for more information.",
|
} else if (!$is_all && !strlen($key_list)) {
|
||||||
'--purge-all',
|
throw new PhutilArgumentUsageException(
|
||||||
implode(', ', $list),
|
pht(
|
||||||
'--help'));
|
'Select caches to purge with "--all" or "--caches". Available '.
|
||||||
|
'caches are: %s.',
|
||||||
|
implode(', ', array_keys($all_purgers))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($purge['remarkup']) {
|
if ($is_all) {
|
||||||
$console->writeOut(pht('Purging remarkup cache...'));
|
$purgers = $all_purgers;
|
||||||
$this->purgeRemarkupCache();
|
} else {
|
||||||
$console->writeOut("%s\n", pht('Done.'));
|
$key_list = preg_split('/[\s,]+/', $key_list);
|
||||||
|
$purgers = array();
|
||||||
|
foreach ($key_list as $key) {
|
||||||
|
if (isset($all_purgers[$key])) {
|
||||||
|
$purgers[$key] = $all_purgers[$key];
|
||||||
|
} else {
|
||||||
|
throw new PhutilArgumentUsageException(
|
||||||
|
pht(
|
||||||
|
'Cache purger "%s" is not recognized. Available caches '.
|
||||||
|
'are: %s.',
|
||||||
|
$key,
|
||||||
|
implode(', ', array_keys($all_purgers))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$purgers) {
|
||||||
|
throw new PhutilArgumentUsageException(
|
||||||
|
pht(
|
||||||
|
'When using "--caches", you must select at least one valid '.
|
||||||
|
'cache to purge.'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($purge['changeset']) {
|
foreach ($purgers as $key => $purger) {
|
||||||
$console->writeOut(pht('Purging changeset cache...'));
|
echo tsprintf(
|
||||||
$this->purgeChangesetCache();
|
"%s\n",
|
||||||
$console->writeOut("%s\n", pht('Done.'));
|
pht(
|
||||||
|
'Purging "%s" cache...',
|
||||||
|
$key));
|
||||||
|
|
||||||
|
$purger->purgeCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($purge['general']) {
|
return 0;
|
||||||
$console->writeOut(pht('Purging general cache...'));
|
|
||||||
$this->purgeGeneralCache();
|
|
||||||
$console->writeOut("%s\n", pht('Done.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($purge['user']) {
|
|
||||||
$console->writeOut(pht('Purging user cache...'));
|
|
||||||
$this->purgeUserCache();
|
|
||||||
$console->writeOut("%s\n", pht('Done.'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function purgeRemarkupCache() {
|
|
||||||
$conn_w = id(new PhabricatorMarkupCache())->establishConnection('w');
|
|
||||||
|
|
||||||
queryfx(
|
|
||||||
$conn_w,
|
|
||||||
'TRUNCATE TABLE %T',
|
|
||||||
id(new PhabricatorMarkupCache())->getTableName());
|
|
||||||
}
|
|
||||||
|
|
||||||
private function purgeChangesetCache() {
|
|
||||||
$conn_w = id(new DifferentialChangeset())->establishConnection('w');
|
|
||||||
queryfx(
|
|
||||||
$conn_w,
|
|
||||||
'TRUNCATE TABLE %T',
|
|
||||||
DifferentialChangeset::TABLE_CACHE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function purgeGeneralCache() {
|
|
||||||
$conn_w = id(new PhabricatorMarkupCache())->establishConnection('w');
|
|
||||||
|
|
||||||
queryfx(
|
|
||||||
$conn_w,
|
|
||||||
'TRUNCATE TABLE %T',
|
|
||||||
'cache_general');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function purgeUserCache() {
|
|
||||||
$table = new PhabricatorUserCache();
|
|
||||||
$conn_w = $table->establishConnection('w');
|
|
||||||
|
|
||||||
queryfx(
|
|
||||||
$conn_w,
|
|
||||||
'TRUNCATE TABLE %T',
|
|
||||||
$table->getTableName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
30
src/applications/cache/purger/PhabricatorCachePurger.php
vendored
Normal file
30
src/applications/cache/purger/PhabricatorCachePurger.php
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
abstract class PhabricatorCachePurger
|
||||||
|
extends Phobject {
|
||||||
|
|
||||||
|
private $viewer;
|
||||||
|
|
||||||
|
abstract public function purgeCache();
|
||||||
|
|
||||||
|
final public function setViewer(PhabricatorUser $viewer) {
|
||||||
|
$this->viewer = $viewer;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getViewer() {
|
||||||
|
return $this->viewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getPurgerKey() {
|
||||||
|
return $this->getPhobjectClassConstant('PURGERKEY');
|
||||||
|
}
|
||||||
|
|
||||||
|
final public static function getAllPurgers() {
|
||||||
|
return id(new PhutilClassMapQuery())
|
||||||
|
->setAncestorClass(__CLASS__)
|
||||||
|
->setUniqueMethod('getPurgerKey')
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/applications/cache/purger/PhabricatorChangesetCachePurger.php
vendored
Normal file
18
src/applications/cache/purger/PhabricatorChangesetCachePurger.php
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorChangesetCachePurger
|
||||||
|
extends PhabricatorCachePurger {
|
||||||
|
|
||||||
|
const PURGERKEY = 'changeset';
|
||||||
|
|
||||||
|
public function purgeCache() {
|
||||||
|
$table = new DifferentialChangeset();
|
||||||
|
$conn = $table->establishConnection('w');
|
||||||
|
|
||||||
|
queryfx(
|
||||||
|
$conn,
|
||||||
|
'TRUNCATE TABLE %T',
|
||||||
|
DifferentialChangeset::TABLE_CACHE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/applications/cache/purger/PhabricatorGeneralCachePurger.php
vendored
Normal file
18
src/applications/cache/purger/PhabricatorGeneralCachePurger.php
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorGeneralCachePurger
|
||||||
|
extends PhabricatorCachePurger {
|
||||||
|
|
||||||
|
const PURGERKEY = 'general';
|
||||||
|
|
||||||
|
public function purgeCache() {
|
||||||
|
$table = new PhabricatorMarkupCache();
|
||||||
|
$conn = $table->establishConnection('w');
|
||||||
|
|
||||||
|
queryfx(
|
||||||
|
$conn,
|
||||||
|
'TRUNCATE TABLE %T',
|
||||||
|
'cache_general');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/applications/cache/purger/PhabricatorRemarkupCachePurger.php
vendored
Normal file
18
src/applications/cache/purger/PhabricatorRemarkupCachePurger.php
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorRemarkupCachePurger
|
||||||
|
extends PhabricatorCachePurger {
|
||||||
|
|
||||||
|
const PURGERKEY = 'remarkup';
|
||||||
|
|
||||||
|
public function purgeCache() {
|
||||||
|
$table = new PhabricatorMarkupCache();
|
||||||
|
$conn = $table->establishConnection('w');
|
||||||
|
|
||||||
|
queryfx(
|
||||||
|
$conn,
|
||||||
|
'TRUNCATE TABLE %T',
|
||||||
|
$table->getTableName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/applications/cache/purger/PhabricatorUserCachePurger.php
vendored
Normal file
18
src/applications/cache/purger/PhabricatorUserCachePurger.php
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorUserCachePurger
|
||||||
|
extends PhabricatorCachePurger {
|
||||||
|
|
||||||
|
const PURGERKEY = 'user';
|
||||||
|
|
||||||
|
public function purgeCache() {
|
||||||
|
$table = new PhabricatorUserCache();
|
||||||
|
$conn = $table->establishConnection('w');
|
||||||
|
|
||||||
|
queryfx(
|
||||||
|
$conn,
|
||||||
|
'TRUNCATE TABLE %T',
|
||||||
|
$table->getTableName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue