Changeset View
Changeset View
Standalone View
Standalone View
src/applications/cache/PhabricatorCaches.php
| <?php | <?php | ||||
| /** | /** | ||||
| * | |||||
| * @task request Request Cache | |||||
| * @task immutable Immutable Cache | * @task immutable Immutable Cache | ||||
| * @task setup Setup Cache | * @task setup Setup Cache | ||||
| * @task compress Compression | * @task compress Compression | ||||
| */ | */ | ||||
| final class PhabricatorCaches { | final class PhabricatorCaches { | ||||
| private static $requestCache; | |||||
| public static function getNamespace() { | public static function getNamespace() { | ||||
| return PhabricatorEnv::getEnvConfig('phabricator.cache-namespace'); | return PhabricatorEnv::getEnvConfig('phabricator.cache-namespace'); | ||||
| } | } | ||||
| private static function newStackFromCaches(array $caches) { | private static function newStackFromCaches(array $caches) { | ||||
| $caches = self::addNamespaceToCaches($caches); | $caches = self::addNamespaceToCaches($caches); | ||||
| $caches = self::addProfilerToCaches($caches); | $caches = self::addProfilerToCaches($caches); | ||||
| return id(new PhutilKeyValueCacheStack()) | return id(new PhutilKeyValueCacheStack()) | ||||
| ->setCaches($caches); | ->setCaches($caches); | ||||
| } | } | ||||
| /* -( Request Cache )------------------------------------------------------ */ | |||||
| /** | |||||
| * Get a request cache stack. | |||||
| * | |||||
| * This cache stack is destroyed after each logical request. In particular, | |||||
| * it is destroyed periodically by the daemons, while `static` caches are | |||||
| * not. | |||||
| * | |||||
| * @return PhutilKeyValueCacheStack Request cache stack. | |||||
| */ | |||||
| public static function getRequestCache() { | |||||
| if (!self::$requestCache) { | |||||
| self::$requestCache = new PhutilInRequestKeyValueCache(); | |||||
| } | |||||
| return self::$requestCache; | |||||
| } | |||||
| /** | |||||
| * Destroy the request cache. | |||||
| * | |||||
| * This is called at the beginning of each logical request. | |||||
| * | |||||
| * @return void | |||||
| */ | |||||
| public static function destroyRequestCache() { | |||||
| self::$requestCache = null; | |||||
| } | |||||
| /* -( Local Cache )-------------------------------------------------------- */ | /* -( Immutable Cache )---------------------------------------------------- */ | ||||
| /** | /** | ||||
| * Gets an immutable cache stack. | * Gets an immutable cache stack. | ||||
| * | * | ||||
| * This stack trades mutability away for improved performance. Normally, it is | * This stack trades mutability away for improved performance. Normally, it is | ||||
| * APC + DB. | * APC + DB. | ||||
| * | * | ||||
| ▲ Show 20 Lines • Show All 319 Lines • Show Last 20 Lines | |||||