/** * @task setup */ private static function buildSetupCaches() { // 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 PhutilAPCKeyValueCache(); if ($apc->isAvailable()) { return array($apc); } // If we don't have APC, build a poor approximation on disk. This is still // much better than nothing; some setup steps are quite slow. $disk_path = self::getSetupCacheDiskCachePath(); if ($disk_path) { $disk = new PhutilOnDiskKeyValueCache(); $disk->setCacheFile($disk_path); $disk->setWait(0.1); if ($disk->isAvailable()) { return array($disk); } } return array(); }
public function testCacheStack() { $req_cache = new PhutilInRequestKeyValueCache(); $disk_cache = new PhutilOnDiskKeyValueCache(); $disk_cache->setCacheFile(new TempFile()); $apc_cache = new PhutilAPCKeyValueCache(); $stack = array($req_cache, $disk_cache); if ($apc_cache->isAvailable()) { $stack[] = $apc_cache; } $cache = new PhutilKeyValueCacheStack(); $cache->setCaches($stack); $this->doCacheTest($cache); $disk_cache->destroyCache(); $req_cache->destroyCache(); }