php8.5
Home/ Manual/ memcached / memcached/ Memcached::getByKey

Memcached::getByKey

PHP function Edit on GitHub ✎

(PECL memcached >= 0.1.0)

Retrieve an item from a specific server

Description

Memcached::getByKey(string $server_key, string $key, callable|null $cache_cb = null, int $get_flags = 0): mixed

Memcached::getByKey() is functionally equivalent to Memcached::get, except that the free-form server_key can be used to map the key to a specific server.

Parameters

server_key

Server_key

key

The key of the item to fetch.

cache_cb

Read-through caching callback or null

get_flags

Flags to control the returned result. When value of Memcached::GET_EXTENDED is given will return the CAS token.

Return Values

Returns the value stored in the cache or false otherwise. The Memcached::getResultCode will return Memcached::RES_NOTFOUND if the key does not exist.

Changelog

VersionDescription
PECL memcached 3.0.0The cas_token parameter was removed. Instead get_flags was added and when it is given the value of Memcached::GET_EXTENDED it will ensure the CAS token to be fetched.

See Also

  • Memcached::get
  • Memcached::getMulti
  • Memcached::getDelayed

Source: reference/memcached/memcached/getbykey.xml · from the official PHP manual (php/doc-en)