當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Cache_Core::setOption方法代碼示例

本文整理匯總了PHP中Zend_Cache_Core::setOption方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Cache_Core::setOption方法的具體用法?PHP Zend_Cache_Core::setOption怎麽用?PHP Zend_Cache_Core::setOption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Cache_Core的用法示例。


在下文中一共展示了Zend_Cache_Core::setOption方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init

 /**
  *
  */
 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);
 }
開發者ID:Gerhard13,項目名稱:pimcore,代碼行數:57,代碼來源:Cache.php

示例2: init

 /**
  *
  */
 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);
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:56,代碼來源:Cache.php

示例3: setOption

 /**
  * Public frontend to set an option
  *
  * Just a wrapper to get a specific behaviour for cached_entity
  *
  * @param  string $name  Name of the option
  * @param  mixed  $value Value of the option
  * @throws Zend_Cache_Exception
  * @return void
  */
 public function setOption($name, $value)
 {
     if ($name == 'cached_entity') {
         $this->setCachedEntity($value);
     } else {
         parent::setOption($name, $value);
     }
 }
開發者ID:quangbt2005,項目名稱:vhost-kis,代碼行數:18,代碼來源:Class.php

示例4: setOption

 /**
  * Public frontend to set an option
  *
  * Just a wrapper to get a specific behaviour for master_file
  *
  * @param  string $name  Name of the option
  * @param  mixed  $value Value of the option
  * @throws Zend_Cache_Exception
  * @return void
  */
 public function setOption($name, $value)
 {
     if ($name == 'master_file') {
         $this->setMasterFile($value);
     } else {
         if ($name == 'master_files') {
             $this->setMasterFiles($value);
         } else {
             parent::setOption($name, $value);
         }
     }
 }
開發者ID:rdallasgray,項目名稱:zf,代碼行數:22,代碼來源:File.php

示例5: _setupCache

 /**
  * Setup Cache
  *
  * @param Zend_Config $config
  */
 protected function _setupCache(Zend_Config $config)
 {
     // Disable cache
     if (!$config->get('cache')->get('enabled') || !extension_loaded('apc')) {
         if ($this->_cache instanceof Zend_Cache_Core) {
             $this->_cache->setOption('caching', false);
         } else {
             $this->_cache = Zend_Cache::factory('Core', 'File', array('caching' => false));
         }
         return;
     }
     if (!extension_loaded('apc')) {
         /**
          * @see Zym_App_Exception
          */
         require_once 'Zym/App/Exception.php';
         throw new Zym_App_Exception('Extension "Apc" is required to use "' . get_class($this) . '"\'s cache feature. ' . 'Disable caching or set your own cache object.');
     }
     $prefix = sprintf($config->get('cache')->get('prefix'), $this->getName(true));
     $this->_cache = Zend_Cache::factory('Core', 'Apc', array('automatic_serialization' => true, 'cache_id_prefix' => $prefix));
 }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:26,代碼來源:App.php

示例6: setCache

 /**
  * Affecte le cache
  *
  * @param Zend_Cache_Core $cache
  */
 public static function setCache(Zend_Cache_Core $cache)
 {
     $cache->setOption('automatic_serialization', true);
     static::$_cache = $cache;
 }
開發者ID:nikoul,項目名稱:Projet-PHP-WebRadio,代碼行數:10,代碼來源:CacheAcl.php


注:本文中的Zend_Cache_Core::setOption方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。