结果回调

结果 callableMemcached::getDelayed()Memcached::getDelayedBykey() 方法对结果集中的每个项目进行调用。回调函数可以接收到一个 Memcached 对象合一个数组描述的元素信息,此回调函数不需要返回任何信息。

示例 #1 结果回调示例

<?php
$m
= new Memcached();
$m->addServer('localhost', 11211);
$items = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'
);
$m->setMulti($items);
$m->getDelayed(array('key1', 'key3'), true, 'result_cb');

function
result_cb($memc, $item)
{
var_dump($item);
}
?>

以上例程的输出类似于:

array(3) {
  ["key"]=>
  string(4) "key1"
  ["value"]=>
  string(6) "value1"
  ["cas"]=>
  float(49)
}
array(3) {
  ["key"]=>
  string(4) "key3"
  ["value"]=>
  string(6) "value3"
  ["cas"]=>
  float(50)
}
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top