本文整理汇总了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;
}
示例2: getValueByKey
public function getValueByKey($key)
{
return parent::getByKey($this->server, $key);
}