Memcache::get

(PECL memcache >= 0.2.0)

Memcache::getRetrieve item from the server

Açıklama

Memcache::get(string$key, int&$flags = ?): string
Memcache::get(array$keys, array&$flags = ?): array

Memcache::get() returns previously stored data of an item, if such key exists on the server at this moment.

You can pass array of keys to Memcache::get() to get array of values. The result array will contain only found key-value pairs.

Bağımsız Değişkenler

key

The key or array of keys to fetch.

flags

If present, flags fetched along with the values will be written to this parameter. These flags are the same as the ones given to for example Memcache::set(). The lowest byte of the int is reserved for pecl/memcache internal usage (e.g. to indicate compression and serialization status).

Dönen Değerler

Returns the value associated with the key or an array of found key-value pairs when key is an array. Returns false on failure, key is not found or key is an empty array.

Örnekler

Örnek 1 Memcache::get() example

<?php


$memcache_obj = memcache_connect('memcache_host', 11211);
$var = memcache_get($memcache_obj, 'some_key');


$memcache_obj = new Memcache;
$memcache_obj->connect('memcache_host', 11211);
$var = $memcache_obj->get('some_key');




$memcache_obj = memcache_connect('memcache_host', 11211);
$var = memcache_get($memcache_obj, Array('some_key', 'another_key'));


$memcache_obj = new Memcache;
$memcache_obj->connect('memcache_host', 11211);
$var = $memcache_obj->get(Array('some_key', 'second_key'));

?>
To Top