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


PHP Zend_Cache_Backend::save方法代碼示例

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


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

示例1: load

 /**
  * Test if a cache is available for the given id and (if yes) return it (false else)
  *
  * Note : return value is always "string" (unserialization is done by the core not by the backend)
  *
  * @param  string  $id                     Cache id
  * @param  boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
  * @return string|false cached datas
  */
 public function load($id, $doNotTestCacheValidity = false)
 {
     self::_validateIdOrTag($id);
     $res = $this->_fastBackend->load($id, $doNotTestCacheValidity);
     if ($res === false) {
         $res = $this->_slowBackend->load($id, $doNotTestCacheValidity);
         if ($res === false) {
             // there is no cache at all for this id
             return false;
         }
     }
     $array = unserialize($res);
     // maybe, we have to refresh the fast cache ?
     if ($this->_options['auto_refresh_fast_cache']) {
         if ($array['priority'] == 10) {
             // no need to refresh the fast cache with priority = 10
             return $array['data'];
         }
         $newFastLifetime = $this->_getFastLifetime($array['lifetime'], $array['priority'], time() - $array['expire']);
         // we have the time to refresh the fast cache
         $usage = $this->_getFastFillingPercentage('loading');
         if ($array['priority'] > 0 && 10 * $array['priority'] >= $usage) {
             // we can refresh the fast cache
             $preparedData = $this->_prepareData($array['data'], $array['lifetime'], $array['priority']);
             $this->_fastBackend->save($preparedData, $id, array(), $newFastLifetime);
         }
     }
     return $array['data'];
 }
開發者ID:padraic,項目名稱:zfcache,代碼行數:38,代碼來源:TwoLevels.php

示例2: Set

 /**
  * Записать значение в кеш
  *
  * @param  mixed  $data	Данные для хранения в кеше
  * @param  string $sName	Имя ключа
  * @param  array  $aTags	Список тегов, для возможности удалять сразу несколько кешей по тегу
  * @param  int    $iTimeLife	Время жизни кеша в секундах
  * @return bool
  */
 public function Set($data, $sName, $aTags = array(), $iTimeLife = false)
 {
     if (!$this->bUseCache) {
         return false;
     }
     /**
      * Т.к. название кеша может быть любым то предварительно хешируем имя кеша
      */
     $sName = md5(Config::Get('sys.cache.prefix') . $sName);
     if ($this->sCacheType == SYS_CACHE_TYPE_FILE) {
         $data = serialize($data);
     }
     return $this->oBackendCache->save($data, $sName, $aTags, $iTimeLife);
 }
開發者ID:lunavod,項目名稱:bunker_stable,代碼行數:23,代碼來源:Cache.class.php

示例3: save

 /**
  * Save some string datas into a cache record
  *
  * Note : $data is always "string" (serialization is done by the
  * core not by the backend)
  *
  * @param  string $data             Datas to cache
  * @param  string $cacheId          Cache id
  * @param  string[] $tags           Array of strings, the cache record will be tagged by each string entry
  * @param  bool $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
  * @return bool true if no problem
  */
 public function save($data, $cacheId, $tags = [], $specificLifetime = false, $priority = 8)
 {
     return $this->_backend->save($data, $cacheId, $tags, $specificLifetime, $priority);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:19,代碼來源:AbstractDecorator.php


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