1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 17:28:51 +02:00

Add wait for setup issue fallback disk cache

Summary: See D5657. Also cleans up the namespacing stuff a little bit.

Test Plan: Disabled APC and verified that setup checks didn't run normally, but did run after restart and on `/config/issue/`.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D5658
This commit is contained in:
epriestley 2013-04-13 07:09:32 -07:00
parent e31e998f3b
commit dd4d8067f1

View file

@ -30,6 +30,7 @@ final class PhabricatorCaches {
static $cache;
if (!$cache) {
$caches = self::buildSetupCaches();
$caches = self::addNamespaceToCaches($caches);
$caches = self::addProfilerToCaches($caches);
$cache = id(new PhutilKeyValueCacheStack())
->setCaches($caches);
@ -45,12 +46,6 @@ 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);
}
@ -60,13 +55,8 @@ 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);
$disk->setWait(0.1);
if ($disk->isAvailable()) {
return array($disk);
}
@ -183,4 +173,19 @@ final class PhabricatorCaches {
return $caches;
}
private static function addNamespaceToCaches(array $caches) {
$namespace = PhabricatorCaches::getNamespace();
if (!$namespace) {
return $caches;
}
foreach ($caches as $key => $cache) {
$ncache = new PhutilKeyValueCacheNamespace($cache);
$ncache->setNamespace($namespace);
$caches[$key] = $ncache;
}
return $caches;
}
}