/** * Returns a instance of the cache, if the instance isn't available it creates a new one * * @return Zend_Cache_Core|Zend_Cache_Frontend */ public static function getInstance() { if (!empty($_REQUEST["nocache"])) { self::disable(); } if (!self::$instance instanceof Zend_Cache_Core) { // default file based configuration $config = self::getDefaultConfig(); // check for custom cache configuration $customCacheFile = PIMCORE_CONFIGURATION_DIRECTORY . "/cache.xml"; if (is_file($customCacheFile)) { try { $conf = new Zend_Config_Xml($customCacheFile); if ($conf->frontend) { $config["frontendType"] = (string) $conf->frontend->type; $config["customFrontendNaming"] = (bool) $conf->frontend->custom; if ($conf->frontend->options) { $config["frontendConfig"] = $conf->frontend->options->toArray(); } } if ($conf->backend) { $config["backendType"] = (string) $conf->backend->type; $config["customBackendNaming"] = (bool) $conf->backend->custom; if ($conf->backend->options) { $config["backendConfig"] = $conf->backend->options->toArray(); } } } catch (Exception $e) { Logger::error($e); Logger::error("Error while reading cache configuration"); } } self::$defaultLifetime = $config["frontendConfig"]["lifetime"]; // here you can use the cache backend you like try { self::$instance = self::initializeCache($config); } catch (Exception $e) { Logger::warning("can't initialize cache with the given configuration " . $e->getMessage()); } } // return default cache if cache cannot be initialized if (!self::$instance instanceof Zend_Cache_Core) { self::$instance = self::getDefaultCache(); } // reset default lifetime self::$instance->setLifetime(self::$defaultLifetime); return self::$instance; }