当前位置: 首页>>代码示例>>PHP>>正文


PHP Memcached::append方法代码示例

本文整理汇总了PHP中Memcached::append方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::append方法的具体用法?PHP Memcached::append怎么用?PHP Memcached::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Memcached的用法示例。


在下文中一共展示了Memcached::append方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 /**
  * {@inheritdoc}
  */
 public function add(string $alias, FeatureInterface $feature) : StorageInterface
 {
     $key = $this->key($alias);
     $this->memcached->set($key, $this->feature($feature));
     if (!$this->memcached->append($this->prefix, "|{$key}")) {
         $this->memcached->set($this->prefix, $key);
     }
     return $this;
 }
开发者ID:jadb,项目名称:feature_toggle,代码行数:12,代码来源:MemcachedStorage.php

示例2: 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

示例3: append

 /**
  * Appends a value to the end of an existing cached value.
  *
  * If the value doesn't exist, it will be set with the given value
  *
  * @param String $key The key for the value
  * @param mixed $value The value to append
  * @param Integer $expire The lifespan of this cache value, in seconds
  * @return \r8\Cache\Memcached Returns a self reference
  */
 public function append($key, $value, $expire = 0)
 {
     if (!$this->memcached->append($this->prepareKey($key), (string) $value)) {
         $this->set($key, $value, $expire);
     }
     $this->handleErrors();
     return $this;
 }
开发者ID:Nycto,项目名称:Round-Eights,代码行数:18,代码来源:Memcached.php

示例4: append

 public function append($key, $data)
 {
     $this->ensureTriedToConnect();
     try {
         return $this->instance->append($key, $data);
     } catch (BaseException $e) {
         return $this->alive = false;
     }
 }
开发者ID:justthefish,项目名称:hesper,代码行数:9,代码来源:PeclMemcached.php

示例5: has

 /**
  * {@inheritdoc }
  */
 public function has($key)
 {
     /* It seems that the most efficient way to check has in memcached is
        by using an append with an empty string. However, we need to make
        sure that OPT_COMPRESSION is turned off because you can't append
        if you compressing data */
     /* store for later use */
     $cur_compression = $this->adapter->getOption(BaseMemcached::OPT_COMPRESSION);
     /* set compression off */
     $this->adapter->setOption(BaseMemcached::OPT_COMPRESSION, false);
     $res = $this->adapter->append($this->buildKey($key), '');
     $this->adapter->setOption(BaseMemcached::OPT_COMPRESSION, $cur_compression);
     return $res;
 }
开发者ID:BrightLocal,项目名称:Cache,代码行数:17,代码来源:Memcached.php

示例6: append

 /**
  * 向已存在元素后追加数据
  * @param string|array $key
  * @param mixed $value
  */
 public function append($key = NULL, $value = NULL)
 {
     $this->local_cache[$this->key_name($key)] = $value;
     switch ($this->client_type) {
         case 'Memcache':
             $append_status = $this->m->append($this->key_name($key), $value);
             break;
         default:
         case 'Memcached':
             $append_status = $this->m->append($this->key_name($key), $value);
             break;
     }
     return $append_status;
 }
开发者ID:babety,项目名称:HellaEngine,代码行数:19,代码来源:Memcached.php

示例7: testAppendCasRaceFailed

 public function testAppendCasRaceFailed()
 {
     $request = new MemcacheGetRequest();
     $request->addKey("widgets_float");
     $request->setForCas(true);
     $response = new MemcacheGetResponse();
     $item = $response->addItem();
     $item->setKey("widgets_float");
     $item->setValue("bar");
     $item->setFlags(0);
     // string.
     $item->setCasId(123456);
     $this->apiProxyMock->expectCall('memcache', 'Get', $request, $response);
     $request = new MemcacheSetRequest();
     $item = $request->addItem();
     $item->setKey("widgets_float");
     $item->setValue("barfoo");
     $item->setFlags(0);
     // string
     $item->setCasId(123456);
     $item->setSetPolicy(SetPolicy::CAS);
     $item->setExpirationTime(0);
     $response = new MemcacheSetResponse();
     $response->addSetStatus(SetStatusCode::EXISTS);
     $this->apiProxyMock->expectCall('memcache', 'Set', $request, $response);
     $request = new MemcacheGetRequest();
     $request->addKey("widgets_float");
     $request->setForCas(true);
     $response = new MemcacheGetResponse();
     $item = $response->addItem();
     $item->setKey("widgets_float");
     $item->setValue("baz");
     $item->setFlags(0);
     // string.
     $item->setCasId(1234567);
     $this->apiProxyMock->expectCall('memcache', 'Get', $request, $response);
     $request = new MemcacheSetRequest();
     $item = $request->addItem();
     $item->setKey("widgets_float");
     $item->setValue("bazfoo");
     $item->setFlags(0);
     // string
     $item->setCasId(1234567);
     $item->setSetPolicy(SetPolicy::CAS);
     $item->setExpirationTime(0);
     $response = new MemcacheSetResponse();
     $response->addSetStatus(SetStatusCode::STORED);
     $this->apiProxyMock->expectCall('memcache', 'Set', $request, $response);
     $memcached = new Memcached();
     $memcached->setOption(Memcached::OPT_PREFIX_KEY, "widgets_");
     $this->assertTrue($memcached->append("float", "foo", 30));
     $this->assertEquals($memcached->getResultCode(), Memcached::RES_SUCCESS);
     $this->apiProxyMock->verify();
 }
开发者ID:spudder-com,项目名称:spudder-django,代码行数:54,代码来源:MemcachedTest.php

示例8: Memcached

<?php

$cache = new Memcached();
$cache->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$cache->setOption(Memcached::OPT_COMPRESSION, false);
$cache->addServer('localhost', 3434);
$cache->add("add_key", "hello", 500);
$cache->append("append_key", "world");
$cache->prepend("prepend_key", "world");
$cache->increment("incr", 2, 1, 500);
$cache->decrement("decr", 2, 1, 500);
$cache->delete("delete_k");
$cache->flush(1);
var_dump($cache->get('get_this'));
$cache->set('set_key', 'value 1', 100);
$cache->replace('replace_key', 'value 2', 200);
$cache->getStats();
$cache->quit();
sleep(1);
开发者ID:awinlei,项目名称:php-memcached,代码行数:19,代码来源:test-server.php

示例9: append

 /**
  * @inheritdoc
  */
 public function append($key, $value, $expiration = null)
 {
     $key = $this->prefix . $key;
     return parent::append($key, $value, $expiration);
 }
开发者ID:jonafrank,项目名称:memcached-manager,代码行数:8,代码来源:MemcachedHandler.php


注:本文中的Memcached::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。