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


PHP false::set方法代碼示例

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


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

示例1: set

 /**
  * Sends a key => value pair to the cache.
  *
  * <code>
  * // This code will add four entries to the cache, one for each url.
  * $cache->set('main', 'http://moodle.org');
  * $cache->set('docs', 'http://docs.moodle.org');
  * $cache->set('tracker', 'http://tracker.moodle.org');
  * $cache->set('qa', 'http://qa.moodle.net');
  * </code>
  *
  * @param string|int $key The key for the data being requested.
  *      It can be any structure although using a scalar string or int is recommended in the interests of performance.
  *      In advanced cases an array may be useful such as in situations requiring the multi-key functionality.
  * @param mixed $data The data to set against the key.
  * @return bool True on success, false otherwise.
  */
 public function set($key, $data)
 {
     if ($this->perfdebug) {
         cache_helper::record_cache_set($this->storetype, $this->definition->get_id());
     }
     if ($this->loader !== false) {
         // We have a loader available set it there as well.
         // We have to let the loader do its own parsing of data as it may be unique.
         $this->loader->set($key, $data);
     }
     if (is_object($data) && $data instanceof cacheable_object) {
         $data = new cache_cached_object($data);
     } else {
         if (!is_scalar($data)) {
             // If data is an object it will be a reference.
             // If data is an array if may contain references.
             // We want to break references so that the cache cannot be modified outside of itself.
             // Call the function to unreference it (in the best way possible).
             $data = $this->unref($data);
         }
     }
     if ($this->has_a_ttl() && !$this->store_supports_native_ttl()) {
         $data = new cache_ttl_wrapper($data, $this->definition->get_ttl());
     }
     $parsedkey = $this->parse_key($key);
     if ($this->is_using_persist_cache()) {
         $this->set_in_persist_cache($parsedkey, $data);
     }
     return $this->store->set($parsedkey, $data);
 }
開發者ID:masaterutakeno,項目名稱:MoodleMobile,代碼行數:47,代碼來源:loaders.php


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