/** * Create and return the instance of phpFastCache\CacheManager * * @return object the instance of the Cache Manager if cache enabled * in the configuration file (config/cache.php), null * if disabled * * @static * @see Cache::clean() * @access public * @since Method available since Release 0.1.0 */ static function init() { if (self::$config === null) { self::$config = Config::get('cache'); } if (self::$config['enabled'] === true) { CacheManager::setup(self::$config['settings']); if (self::$CacheManager === null) { self::$CacheManager = CacheManager::getInstance(); } return self::$CacheManager; } else { return null; } }
/** * Sets the store for cache files. Defaults to * /dev/shm. Must have trailing slash. * * @param string $store The dir to store the cache data in */ public static function setStore($store) { self::$store = $store; }
/** * @param $key * @param int $expires * * @return Cache\CacheInterface */ private static function _Factory($key, $expires = 7200){ if(self::$_Backend === null){ // Load the backend from the site configuration.xml $cs = \ConfigHandler::LoadConfigFile("configuration"); self::$_Backend = $cs['cache_type']; } if(isset(self::$_KeyCache[$key])){ return self::$_KeyCache[$key]; } switch(self::$_Backend){ case 'apc': if(!class_exists('CacheAPC')){ require_once(__CACHE_PDIR . 'backends/cacheapc.class.php'); ##SKIPCOMPILER } $obj = new CacheAPC($key, null, $expires); break; case 'memcache': case 'memcached': if(!class_exists('Core\Cache\Memcache')){ require_once(__CACHE_PDIR . 'Memcache.php'); ##SKIPCOMPILER } $obj = new Cache\Memcache($key, $expires); break; case 'file': default: if(!class_exists('Core\Cache\File')){ require_once(__CACHE_PDIR . 'File.php'); ##SKIPCOMPILER } if(!is_dir(TMP_DIR . 'cache')){ mkdir(TMP_DIR . 'cache'); } $obj = new Cache\File($key, $expires); break; } self::$_KeyCache[$key] = $obj; return $obj; }
public function setTime($time) { self::$time = $time; }