Memcached::getDelayed

(PECL memcached >= 0.1.0)

Memcached::getDelayedSolicita vários itens

Descrição

public Memcached::getDelayed(array $keys, bool $with_cas = false, ?callable $value_cb = null): bool

Memcached::getDelayed() emite uma solicitação ao memcache para vários itens cujas keys são especificadas no array keys. O método não espera resposta e retorna imediatamente. Quando estiver pronto para coletar os itens, chame Memcached::fetch() ou Memcached::fetchAll(). Se with_cas for true, os valores do token CAS também serão solicitados.

Em vez de buscar os resultados explicitamente, você pode especificar um callback de resultado via o parâmetro value_cb.

Parâmetros

keys

Array de keys a ser recuperado.

with_cas

Se os valores de token CAS também devem ser solicitados.

value_cb

O resultado de callback ou null.

Valor Retornado

Retorna true em caso de sucesso ou false em caso de falha. Use Memcached::getResultCode() se necessário.

Exemplos

Exemplo #1 Memcached::getDelayed() exemplo

<?php
$m
= new Memcached();
$m->addServer('localhost', 11211);

$m->set('int', 99);
$m->set('string', 'a simple string');
$m->set('array', array(11, 12));

$m->getDelayed(array('int', 'array'), true);
var_dump($m->fetchAll());
?>

O exemplo acima produzirá:

array(2) {
  [0]=>
  array(3) {
    ["key"]=>
    string(3) "int"
    ["value"]=>
    int(99)
    ["cas"]=>
    float(2363)
  }
  [1]=>
  array(3) {
    ["key"]=>
    string(5) "array"
    ["value"]=>
    array(2) {
      [0]=>
      int(11)
      [1]=>
      int(12)
    }
    ["cas"]=>
    float(2365)
  }
}

Veja Também

add a note add a note

User Contributed Notes 1 note

up
2
antmat at mail dot ru
13 years ago
Actually, when you pass a callback, method doesn't return immediately, but waits for results and calls callback function.
To Top