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


PHP Zend_Cache_Backend_Interface::isAutomaticCleaningAvailable方法代碼示例

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


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

示例1: save

 /**
  * Save some data in a cache
  *
  * @param  mixed $data           Data to put in cache (can be another type than string if automatic_serialization is on)
  * @param  string $id             Cache id (if not set, the last cache id will be used)
  * @param  array $tags           Cache tags
  * @param  int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
  * @param  int   $priority         integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
  * @throws Zend_Cache_Exception
  * @return boolean True if no problem
  */
 public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8)
 {
     if (!$this->_options['caching']) {
         return true;
     }
     if ($id === null) {
         $id = $this->_lastId;
     } else {
         $id = $this->_id($id);
     }
     self::_validateIdOrTag($id);
     self::_validateTagsArray($tags);
     if ($this->_options['automatic_serialization']) {
         // we need to serialize datas before storing them
         $data = serialize($data);
     } else {
         if (!is_string($data)) {
             Zend_Cache::throwException("Datas must be string or set automatic_serialization = true");
         }
     }
     // automatic cleaning
     if ($this->_options['automatic_cleaning_factor'] > 0) {
         $rand = rand(1, $this->_options['automatic_cleaning_factor']);
         if ($rand == 1) {
             if ($this->_extendedBackend) {
                 // New way
                 if ($this->_backendCapabilities['automatic_cleaning']) {
                     $this->clean(Zend_Cache::CLEANING_MODE_OLD);
                 } else {
                     $this->_log('Zend_Cache_Core::save() / automatic cleaning is not available/necessary with this backend');
                 }
             } else {
                 // Deprecated way (will be removed in next major version)
                 if (method_exists($this->_backend, 'isAutomaticCleaningAvailable') && $this->_backend->isAutomaticCleaningAvailable()) {
                     $this->clean(Zend_Cache::CLEANING_MODE_OLD);
                 } else {
                     $this->_log('Zend_Cache_Core::save() / automatic cleaning is not available/necessary with this backend');
                 }
             }
         }
     }
     if ($this->_options['ignore_user_abort']) {
         $abort = ignore_user_abort(true);
     }
     if ($this->_extendedBackend && $this->_backendCapabilities['priority']) {
         $result = $this->_backend->save($data, $id, $tags, $specificLifetime, $priority);
     } else {
         $result = $this->_backend->save($data, $id, $tags, $specificLifetime);
     }
     if ($this->_options['ignore_user_abort']) {
         ignore_user_abort($abort);
     }
     if (!$result) {
         // maybe the cache is corrupted, so we remove it !
         if ($this->_options['logging']) {
             $this->_log("Zend_Cache_Core::save() : impossible to save cache (id={$id})");
         }
         $this->_backend->remove($id);
         return false;
     }
     if ($this->_options['write_control']) {
         $data2 = $this->_backend->load($id, true);
         if ($data != $data2) {
             $this->_log('Zend_Cache_Core::save() / write_control : written and read data do not match');
             $this->_backend->remove($id);
             return false;
         }
     }
     return true;
 }
開發者ID:modulexcite,項目名稱:zfopenid,代碼行數:81,代碼來源:Core.php


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