/** * Load memcache extension if memcache extension is * loaded and if memcache server is avalable * @param $event */ public function handleApplicationCache($event) { if (MEMCACHE_ON) { //Yii::import('application.core.components.ZurmoMemCache'); $memcacheServiceHelper = new MemcacheServiceHelper(); if ($memcacheServiceHelper->runCheckAndGetIfSuccessful()) { $cacheComponent = Yii::createComponent(array('class' => 'CMemCache', 'keyPrefix' => ZURMO_TOKEN, 'servers' => Yii::app()->params['memcacheServers'])); Yii::app()->setComponent('cache', $cacheComponent); } // todo: Find better way to append this prefix for tests. // We can't put this code only in BeginRequestTestBehavior, because for API tests we are using BeginRequestBehavior if (defined('IS_TEST')) { ZurmoCache::setAdditionalStringForCachePrefix('Test'); } } }
/** * Set additional prefix * This is used to distinct memcache value for tests and for website, because test application and * website application use same ZURMO_TOKEN. This prefix is empty for web application, * and for tests it is set to "Test" * @param string $prefix */ public static function setAdditionalStringForCachePrefix($prefix = '') { self::$additionalStringForCachePrefix = $prefix; }