From 074bf4ed7d549703036bfbc2eede136ab4c3bd11 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 14 Dec 2011 15:23:31 -0800 Subject: [PATCH] Add a script for purging long-lived caches Summary: See task; installs occasionally need to do this themselves, and a script is much better than me telling them to truncate tables. Test Plan: Ran various flavors of this command: - purge_cache.php - purge_cache.php derp - purge_cache.php --help - purge_cache.php --all - purge_cache.php --differential - purge_cache.php --differential --maniphest Then I verified the actual behavior: - Visited a Differential revision with comments, observed cache update in 'Services' tab. - Visited a Maniphest task with comments, observed cache update in 'Services' tab. - Reloaded a diff standalone view, got a cache update. Reviewers: Makinde, btrahan, jungejason Reviewed By: jungejason CC: aran, jungejason Maniphest Tasks: T676 Differential Revision: 1214 --- conf/default.conf.php | 3 +- scripts/util/purge_cache.php | 135 +++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 1 deletion(-) create mode 100755 scripts/util/purge_cache.php diff --git a/conf/default.conf.php b/conf/default.conf.php index 4e88b69d10..078c4e128d 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -557,7 +557,8 @@ return array( // against each regexp in order until one matches. The default configuration // uses a width of 100 for Java and 80 for other languages. Note that 80 is // the greatest column width of all time. Changes here will not be immediately - // reflected in old revisions unless you purge the render cache. + // reflected in old revisions unless you purge the changeset render cache + // (with `./scripts/util/purge_cache.php --changesets`). 'differential.wordwrap' => array( '/\.java$/' => 100, '/.*/' => 80, diff --git a/scripts/util/purge_cache.php b/scripts/util/purge_cache.php new file mode 100755 index 0000000000..8db1063a54 --- /dev/null +++ b/scripts/util/purge_cache.php @@ -0,0 +1,135 @@ +#!/usr/bin/env php +establishConnection('w'), + 'TRUNCATE TABLE %T', + DifferentialChangeset::TABLE_CACHE); + echo "Done.\n"; +} + +if ($purge_differential) { + echo "Purging Differential comment cache...\n"; + $table = new DifferentialComment(); + queryfx( + $table->establishConnection('w'), + 'UPDATE %T SET cache = NULL', + $table->getTableName()); + echo "Done.\n"; +} + +if ($purge_maniphest) { + echo "Purging Maniphest comment cache...\n"; + $table = new ManiphestTransaction(); + queryfx( + $table->establishConnection('w'), + 'UPDATE %T SET cache = NULL', + $table->getTableName()); + echo "Done.\n"; +} + +echo "Ok, caches purged.\n"; + +function usage($message) { + echo "Usage Error: {$message}"; + echo "\n\n"; + echo "Run 'purge_cache.php --help' for detailed help.\n"; + exit(1); +} + +function help() { + $help = <<