Memcached::getDelayedByKey
Memcached::getMultiByKey
Memcached
PHP Manual

# Memcached::getMulti

(PECL memcached >= 0.1.0)

Memcached::getMulti — Retrieve multiple items

### Opis

public mixed Memcached::getMulti ( array `$keys` [, array `&$cas_tokens` [, integer `$flags` ]] )

Memcached::getMulti() is similar to Memcached::get, but instead of a single key item, it retrievess multiple items the keys of which are specified in the `keys` array. If `cas_tokens` variable is provided, it is filled with the CAS token values for the found items.

> Informacja: Unlike Memcached::get it is not possible to specify a read-through cache callback for Memcached::getMulti(), because the memcache protocol does not provide information on which keys were not found in the multi-key request.

The `flags` parameter can be used to specify additional options for Memcached::getMulti(). Currently, the only available option is `Memcached::GET_PRESERVE_ORDER` that ensures that the keys are returned in the same order as they were requested in.

### Parametry

`keys`

  Array of keys to retrieve.

`cas_tokens`

  The variable to store the CAS tokens for the found items.

`flags`

  The flags for the get operation.

### Zwracane wartości

Returns the array of found items or `FALSE` on failure. Użyj Memcached::getResultCode, jeśli to konieczne.

### Przykłady

Przykład #1 Memcached::getMulti() example

`<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
$items = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'
);
$m->setMulti($items);
$result = $m->getMulti(array('key1', 'key3', 'badkey'), $cas);
var_dump($result, $cas);
?>`

Powyższy przykład wyświetli coś podobnego do:

    array(2) {
      ["key1"]=>
      string(6) "value1"
      ["key3"]=>
      string(6) "value3"
    }
    array(2) {
      ["key1"]=>
      float(2360)
      ["key3"]=>
      float(2362)
    }

Przykład #2 `Memcached::GET_PRESERVE_ORDER` example

`<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
$data = array(
'foo' => 'foo-data',
'bar' => 'bar-data',
'baz' => 'baz-data',
'lol' => 'lol-data',
'kek' => 'kek-data',
);
$m->setMulti($data, 3600);
$null = null;
$keys = array_keys($data);
$keys[] = 'zoo';
$got = $m->getMulti($keys, $null, Memcached::GET_PRESERVE_ORDER);
foreach ($got as $k => $v) {
echo "$k $v\n";
}
?>`

Powyższy przykład wyświetli coś podobnego do:

    foo foo-data
    bar bar-data
    baz baz-data
    lol lol-data
    kek kek-data
    zoo

### Zobacz też:

- Memcached::getMultiByKey - Retrieve multiple items from a specific server
- Memcached::get - Retrieve an item
- Memcached::getDelayed - Request multiple items

Memcached::getDelayedByKey
Memcached::getMultiByKey
Memcached
PHP Manual