function test_init_with_wrong_server_using_AkCache_lookupStore() { $options = array('enabled'=>true,'handler'=>array('type'=>3,'options'=>array('servers'=>array('test:121')))); $cache=AkCache::lookupStore($options); $this->assertError('Could not connect to MemCache daemon'); $this->assertFalse($cache); }
function _flushCache($host) { $fileCache=AkCache::lookupStore(true); if ($fileCache!==false) { $fileCache->clean($host); } }
public function _flushCache($host) { $settings = Ak::getSettings('caching',false); $fileCache=AkCache::lookupStore($settings); if ($fileCache!==false) { $fileCache->clean($host); } }
/** * @access protected */ function _cache($key, $options = null) { $return = false; if ($this->cacheConfigured()) { $return = $this->_cache_store->fetch(AkCache::expandCacheKey($key, $this->_controller), $options); } return $return; }
/** * Instantiates and configures the AkCache store. * * If $options == NULL the configuration will be taken from the constants: * * AK_CACHE_HANDLER and AK_CACHE_OPTIONS * * if $options is of type string/int the $options parameter will be considered * as the AK_CACHE_HANDLER_* Type (AK_CACHE_HANDLER_PEAR,AK_CACHE_HANDLER_ADODB,AK_CACHE_HANDLER_MEMCACHE) * * if $options is an array of format: * * array('file'=>array('cacheDir'=>'/tmp')) * * or * * array(AK_CACHE_HANDLER_PEAR=>array('cacheDir'=>'/tmp')) * * the first key will be used as the AK_CACHE_HANDLER_* Type * and the array as the config options * * Default behaviour is calling the method with the $options == null parameter: * * AkCache::lookupStore() * * Calling it with: * * AkCache::lookupStore(true) * * will return the configured $cache_store * * @param mixed $options * @return mixed false if no cache could be configured or AkCache instance */ function &lookupStore($options = null) { static $cache_store; $false = false; if ($options === true && !empty($cache_store)) { return $cache_store; } else { if (is_array($options) && isset($options['enabled']) && $options['enabled'] == true && isset($options['handler']) && isset($options['handler']['type'])) { $type = $options['handler']['type']; $options = isset($options['handler']['options']) ? $options['handler']['options'] : array(); } else { if (is_string($options) || is_int($options)) { $type = $options; $options = array(); } else { return $false; } } } $cache_store = new AkCache(); $cache_store->init($options, $type); if ($cache_store->cache_enabled) { return $cache_store; } return $false; }