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


PHP Memcached::appendByKey方法代碼示例

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


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

示例1: append

 /**
  * Append data to an existing item.
  *
  * This method should throw an error if it is used with compressed data. This
  * is an expected behavior. Memcached casts the value to be appended to the initial value to the
  * type of the initial value. Be careful as this leads to unexpected behavior at times. Due to
  * how memcached treats types, the behavior has been mimicked in the internal cache to produce
  * similar results and improve consistency. It is recommend that appends only occur with data of
  * the same type.
  *
  * @link    http://www.php.net/manual/en/memcached.append.php
  *
  * @param   string      $key            The key under which to store the value.
  * @param   mixed       $value          Must be string as appending mixed values is not well-defined.
  * @param   string      $group          The group value appended to the $key.
  * @param   string      $server_key     The key identifying the server to store the value on.
  * @param   bool        $byKey          True to store in internal cache by key; false to not store by key
  * @return  bool                        Returns TRUE on success or FALSE on failure.
  */
 public function append($key, $value, $group = 'default', $server_key = '', $byKey = false)
 {
     if (!is_string($value) && !is_int($value) && !is_float($value)) {
         return false;
     }
     $derived_key = $this->buildKey($key, $group);
     // If group is a non-Memcached group, append to runtime cache value, not Memcached
     if (in_array($group, $this->no_mc_groups)) {
         if (!isset($this->cache[$derived_key])) {
             return false;
         }
         $combined = $this->combine_values($this->cache[$derived_key], $value, 'app');
         $this->add_to_internal_cache($derived_key, $combined);
         return true;
     }
     // Append to Memcached value
     if (false !== $byKey) {
         $result = $this->mc->appendByKey($server_key, $derived_key, $value);
     } else {
         $result = $this->mc->append($derived_key, $value);
     }
     // Store in runtime cache if add was successful
     if (Memcached::RES_SUCCESS === $this->getResultCode()) {
         $combined = $this->combine_values($this->cache[$derived_key], $value, 'app');
         $this->add_to_internal_cache($derived_key, $combined);
     }
     return $result;
 }
開發者ID:Ramoonus,項目名稱:wp-spider-cache,代碼行數:47,代碼來源:class-object-cache.php

示例2: appendByKey

 /**
  * @inheritdoc
  */
 public function appendByKey($server_key, $key, $value, $expiration = null)
 {
     $key = $this->prefix . $key;
     return parent::appendByKey($server_key, $key, $value, $expiration = null);
 }
開發者ID:jonafrank,項目名稱:memcached-manager,代碼行數:8,代碼來源:MemcachedHandler.php


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