Example #1
0
 private function getCache()
 {
     if (($data = $this->_cache->loadCache($this->_key)) != false) {
         return $data;
     }
     return false;
 }
Example #2
0
 private function getCache()
 {
     if (($response = $this->_cache->load($this->_key)) != false) {
         return $response;
     }
     return false;
 }
Example #3
0
 /**
  *
  * @return mixed
  */
 public function getCache()
 {
     if (($response = $this->cache->load($this->key)) != false) {
         return $response;
     }
     return false;
 }
Example #4
0
 /**
  *
  */
 public static function init()
 {
     if (!self::$instance instanceof \Zend_Cache_Core) {
         // check for custom cache configuration
         $customCacheFile = PIMCORE_CONFIGURATION_DIRECTORY . "/cache.xml";
         if (is_file($customCacheFile)) {
             $config = self::getDefaultConfig();
             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 && method_exists($conf->frontend->options, "toArray")) {
                         $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 && method_exists($conf->backend->options, "toArray")) {
                         $config["backendConfig"] = $conf->backend->options->toArray();
                     }
                 }
                 if (isset($config["frontendConfig"]["lifetime"])) {
                     self::$defaultLifetime = $config["frontendConfig"]["lifetime"];
                 }
                 $config = self::normalizeConfig($config);
                 // here you can use the cache backend you like
                 try {
                     self::$instance = self::initializeCache($config);
                 } catch (\Exception $e) {
                     \Logger::crit("can't initialize cache with the given configuration " . $e->getMessage());
                 }
             } catch (\Exception $e) {
                 \Logger::crit($e);
                 \Logger::crit("Error while reading cache configuration, using the default file backend");
             }
         }
     }
     // return default cache if cache cannot be initialized
     if (!self::$instance instanceof \Zend_Cache_Core) {
         self::$instance = self::getDefaultCache();
     }
     self::$instance->setLifetime(self::$defaultLifetime);
     self::$instance->setOption("automatic_serialization", true);
     self::$instance->setOption("automatic_cleaning_factor", 0);
     // init the write lock once (from other processes etc.)
     if (self::$writeLockTimestamp === null) {
         self::$writeLockTimestamp = 0;
         // set the write lock to 0, otherwise infinite loop (self::hasWriteLock() calls self::getInstance())
         self::hasWriteLock();
     }
     self::setZendFrameworkCaches(self::$instance);
 }
Example #5
0
 /**
  *
  */
 public static function init()
 {
     if (!self::$instance instanceof \Zend_Cache_Core) {
         // check for custom cache configuration
         $customConfigFile = \Pimcore\Config::locateConfigFile("cache.php");
         if (is_file($customConfigFile)) {
             $config = self::getDefaultConfig();
             $conf = (include $customConfigFile);
             if (is_array($conf)) {
                 if (isset($conf["frontend"])) {
                     $config["frontendType"] = $conf["frontend"]["type"];
                     $config["customFrontendNaming"] = $conf["frontend"]["custom"];
                     if (isset($conf["frontend"]["options"])) {
                         $config["frontendConfig"] = $conf["frontend"]["options"];
                     }
                 }
                 if (isset($conf["backend"])) {
                     $config["backendType"] = $conf["backend"]["type"];
                     $config["customBackendNaming"] = $conf["backend"]["custom"];
                     if (isset($conf["backend"]["options"])) {
                         $config["backendConfig"] = $conf["backend"]["options"];
                     }
                 }
                 if (isset($config["frontendConfig"]["lifetime"])) {
                     self::$defaultLifetime = $config["frontendConfig"]["lifetime"];
                 }
                 $config = self::normalizeConfig($config);
                 // here you can use the cache backend you like
                 try {
                     self::$instance = self::initializeCache($config);
                 } catch (\Exception $e) {
                     Logger::crit("can't initialize cache with the given configuration " . $e->getMessage());
                 }
             } else {
                 Logger::crit("Error while reading cache configuration, using the default database backend");
             }
         }
     }
     // return default cache if cache cannot be initialized
     if (!self::$instance instanceof \Zend_Cache_Core) {
         self::$instance = self::getDefaultCache();
     }
     self::$instance->setLifetime(self::$defaultLifetime);
     self::$instance->setOption("automatic_serialization", true);
     self::$instance->setOption("automatic_cleaning_factor", 0);
     // init the write lock once (from other processes etc.)
     if (self::$writeLockTimestamp === null) {
         self::$writeLockTimestamp = 0;
         // set the write lock to 0, otherwise infinite loop (self::hasWriteLock() calls self::getInstance())
         self::hasWriteLock();
     }
     self::setZendFrameworkCaches(self::$instance);
 }
Example #6
0
 /**
  * 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;
 }
Example #7
0
 public static function delete($key)
 {
     self::$_cache->delete(self::_multiTenantKey($key));
 }