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


PHP Memcached::casByKey方法代码示例

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


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

示例1: cas

 /**
  * Performs a "check and set" to store data.
  *
  * The set will be successful only if the no other request has updated the value since it was fetched since
  * this request.
  *
  * @link    http://www.php.net/manual/en/memcached.cas.php
  *
  * @param   float       $cas_token      Unique value associated with the existing item. Generated by memcached.
  * @param   string      $key            The key under which to store the value.
  * @param   mixed       $value          The value to store.
  * @param   string      $group          The group value appended to the $key.
  * @param   int         $expiration     The expiration time, defaults to 0.
  * @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 cas($cas_token, $key, $value, $group = 'default', $expiration = 0, $server_key = '', $byKey = false)
 {
     $derived_key = $this->buildKey($key, $group);
     $expiration = $this->sanitize_expiration($expiration);
     /**
      * If group is a non-Memcached group, save to runtime cache, not Memcached. Note
      * that since check and set cannot be emulated in the run time cache, this value
      * operation is treated as a normal "add" for no_mc_groups.
      */
     if (in_array($group, $this->no_mc_groups)) {
         $this->add_to_internal_cache($derived_key, $value);
         return true;
     }
     // Save to Memcached
     if (false !== $byKey) {
         $result = $this->mc->casByKey($cas_token, $server_key, $derived_key, $value, $expiration);
     } else {
         $result = $this->mc->cas($cas_token, $derived_key, $value, $expiration);
     }
     // Store in runtime cache if cas was successful
     if (Memcached::RES_SUCCESS === $this->getResultCode()) {
         $this->add_to_internal_cache($derived_key, $value);
     }
     return $result;
 }
开发者ID:Ramoonus,项目名称:wp-spider-cache,代码行数:42,代码来源:class-object-cache.php

示例2: casByKey

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


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