Differential D16033 Diff 38584 src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php
| Show All 20 Lines | $this | ||||
| array( | array( | ||||
| 'name' => 'purge-changeset', | 'name' => 'purge-changeset', | ||||
| 'help' => pht('Purge the Differential changeset cache.'), | 'help' => pht('Purge the Differential changeset cache.'), | ||||
| ), | ), | ||||
| array( | array( | ||||
| 'name' => 'purge-general', | 'name' => 'purge-general', | ||||
| 'help' => pht('Purge the general cache.'), | '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(); | $console = PhutilConsole::getConsole(); | ||||
| $purge_all = $args->getArg('purge-all'); | $purge_all = $args->getArg('purge-all'); | ||||
| $purge = array( | $purge = array( | ||||
| 'remarkup' => $purge_all || $args->getArg('purge-remarkup'), | 'remarkup' => $purge_all || $args->getArg('purge-remarkup'), | ||||
| 'changeset' => $purge_all || $args->getArg('purge-changeset'), | 'changeset' => $purge_all || $args->getArg('purge-changeset'), | ||||
| 'general' => $purge_all || $args->getArg('purge-general'), | 'general' => $purge_all || $args->getArg('purge-general'), | ||||
| 'user' => $purge_all || $args->getArg('purge-user'), | |||||
| ); | ); | ||||
| if (!array_filter($purge)) { | if (!array_filter($purge)) { | ||||
| $list = array(); | $list = array(); | ||||
| foreach ($purge as $key => $ignored) { | foreach ($purge as $key => $ignored) { | ||||
| $list[] = "'--purge-".$key."'"; | $list[] = "'--purge-".$key."'"; | ||||
| } | } | ||||
| Show All 18 Lines | if ($purge['changeset']) { | ||||
| $console->writeOut("%s\n", pht('Done.')); | $console->writeOut("%s\n", pht('Done.')); | ||||
| } | } | ||||
| if ($purge['general']) { | if ($purge['general']) { | ||||
| $console->writeOut(pht('Purging general cache...')); | $console->writeOut(pht('Purging general cache...')); | ||||
| $this->purgeGeneralCache(); | $this->purgeGeneralCache(); | ||||
| $console->writeOut("%s\n", pht('Done.')); | $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() { | private function purgeRemarkupCache() { | ||||
| $conn_w = id(new PhabricatorMarkupCache())->establishConnection('w'); | $conn_w = id(new PhabricatorMarkupCache())->establishConnection('w'); | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'TRUNCATE TABLE %T', | 'TRUNCATE TABLE %T', | ||||
| Show All 12 Lines | private function purgeGeneralCache() { | ||||
| $conn_w = id(new PhabricatorMarkupCache())->establishConnection('w'); | $conn_w = id(new PhabricatorMarkupCache())->establishConnection('w'); | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'TRUNCATE TABLE %T', | 'TRUNCATE TABLE %T', | ||||
| 'cache_general'); | 'cache_general'); | ||||
| } | } | ||||
| private function purgeUserCache() { | |||||
| $table = new PhabricatorUserCache(); | |||||
| $conn_w = $table->establishConnection('w'); | |||||
| queryfx( | |||||
| $conn_w, | |||||
| 'TRUNCATE TABLE %T', | |||||
| $table->getTableName()); | |||||
| } | |||||
| } | } | ||||