diff --git a/src/applications/cache/PhabricatorCaches.php b/src/applications/cache/PhabricatorCaches.php index 770e833ee9..6e9f5b7fc7 100644 --- a/src/applications/cache/PhabricatorCaches.php +++ b/src/applications/cache/PhabricatorCaches.php @@ -5,6 +5,9 @@ */ final class PhabricatorCaches { + public static function getNamespace() { + return PhabricatorEnv::getEnvConfig('phabricator.cache-namespace'); + } /* -( Setup Cache )-------------------------------------------------------- */ @@ -42,6 +45,12 @@ final class PhabricatorCaches { // In most cases, we should have APC. This is an ideal cache for our // purposes -- it's fast and empties on server restart. $apc = new PhutilKeyValueCacheAPC(); + + if (PhabricatorCaches::getNamespace()) { + $apc = id(new PhutilKeyValueCacheNamespace($apc)) + ->setNamespace(PhabricatorCaches::getNamespace()); + } + if ($apc->isAvailable()) { return array($apc); } @@ -51,6 +60,12 @@ final class PhabricatorCaches { $disk_path = self::getSetupCacheDiskCachePath(); if ($disk_path) { $disk = new PhutilKeyValueCacheOnDisk(); + + if (PhabricatorCaches::getNamespace()) { + $disk = id(new PhutilKeyValueCacheNamespace($disk)) + ->setNamespace(PhabricatorCaches::getNamespace()); + } + $disk->setCacheFile($disk_path); if ($disk->isAvailable()) { return array($disk); diff --git a/src/applications/config/option/PhabricatorCoreConfigOptions.php b/src/applications/config/option/PhabricatorCoreConfigOptions.php index 432c0aac49..c608e4f4e5 100644 --- a/src/applications/config/option/PhabricatorCoreConfigOptions.php +++ b/src/applications/config/option/PhabricatorCoreConfigOptions.php @@ -139,7 +139,11 @@ final class PhabricatorCoreConfigOptions ->setLocked(true) ->setDescription( pht('Custom HTML to show on the main Phabricator dashboard.')), + $this->newOption('phabricator.cache-namespace', 'string', null) + ->setLocked(true) + ->setDescription(pht('Cache namespace.')), ); + } protected function didValidateOption(