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


PHP Memcached::getByKey方法代码示例

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


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

示例1: get

 /**
  * Retrieve object from cache.
  *
  * Gets an object from cache based on $key and $group. In order to fully support the $cache_cb and $cas_token
  * parameters, the runtime cache is ignored by this function if either of those values are set. If either of
  * those values are set, the request is made directly to the memcached server for proper handling of the
  * callback and/or token. Note that the $cas_token variable cannot be directly passed to the function. The
  * variable need to be first defined with a non null value.
  *
  * If using the $cache_cb argument, the new value will always have an expiration of time of 0 (forever). This
  * is a limitation of the Memcached PECL extension.
  *
  * @link http://www.php.net/manual/en/memcached.get.php
  *
  * @param   string          $key        The key under which to store the value.
  * @param   string          $group      The group value appended to the $key.
  * @param   bool            $force      Whether or not to force a cache invalidation.
  * @param   null|bool       $found      Variable passed by reference to determine if the value was found or not.
  * @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
  * @param   null|callable   $cache_cb   Read-through caching callback.
  * @param   null|float      $cas_token  The variable to store the CAS token in.
  * @return  bool|mixed                  Cached object value.
  */
 public function get($key, $group = 'default', $force = false, &$found = null, $server_key = '', $byKey = false, $cache_cb = NULL, &$cas_token = NULL)
 {
     $derived_key = $this->buildKey($key, $group);
     // Assume object is not found
     $found = false;
     // If either $cache_db, or $cas_token is set, must hit Memcached and bypass runtime cache
     if (func_num_args() > 6 && !in_array($group, $this->no_mc_groups)) {
         if (false !== $byKey) {
             $value = $this->mc->getByKey($server_key, $derived_key, $cache_cb, $cas_token);
         } else {
             $value = $this->mc->get($derived_key, $cache_cb, $cas_token);
         }
     } else {
         if (isset($this->cache[$derived_key])) {
             $found = true;
             return is_object($this->cache[$derived_key]) ? clone $this->cache[$derived_key] : $this->cache[$derived_key];
         } elseif (in_array($group, $this->no_mc_groups)) {
             return false;
         } else {
             if (false !== $byKey) {
                 $value = $this->mc->getByKey($server_key, $derived_key);
             } else {
                 $value = $this->mc->get($derived_key);
             }
         }
     }
     if (Memcached::RES_SUCCESS === $this->getResultCode()) {
         $this->add_to_internal_cache($derived_key, $value);
         $found = true;
     }
     return is_object($value) ? clone $value : $value;
 }
开发者ID:Ramoonus,项目名称:wp-spider-cache,代码行数:56,代码来源:class-object-cache.php

示例2: getValueByKey

 public function getValueByKey($key)
 {
     return parent::getByKey($this->server, $key);
 }
开发者ID:jkhaled,项目名称:bms,代码行数:4,代码来源:MyCache.php


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