本文整理汇总了PHP中Memcached::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::fetch方法的具体用法?PHP Memcached::fetch怎么用?PHP Memcached::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached
的用法示例。
在下文中一共展示了Memcached::fetch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
/**
* Fetches the next item from result set
*
* @return array|boolean The next item or false
* @see fetchAll()
*
* @triggers fetch.pre(PreEvent)
* @triggers fetch.post(PostEvent)
* @triggers fetch.exception(ExceptionEvent)
*/
public function fetch()
{
if (!$this->stmtActive) {
return false;
}
$args = new ArrayObject();
try {
$eventRs = $this->triggerPre(__FUNCTION__, $args);
if ($eventRs->stopped()) {
return $eventRs->last();
}
$result = $this->memcached->fetch();
if (!empty($result)) {
$select =& $this->stmtOptions['select'];
// handle selected key
if (!in_array('key', $select)) {
unset($result['key']);
}
// handle selected value
if (!in_array('value', $select)) {
unset($result['value']);
}
} else {
// clear stmt
$this->stmtActive = false;
$this->stmtOptions = null;
}
return $this->triggerPost(__FUNCTION__, $args, $result);
} catch (\Exception $e) {
return $this->triggerException(__FUNCTION__, $args, $e);
}
}
示例2: internalFetch
/**
* Internal method to fetch the next item from result set
*
* @return array|boolean The next item or false
* @throws Exception\ExceptionInterface
*/
protected function internalFetch()
{
if (!$this->stmtActive) {
return false;
}
$result = $this->memcached->fetch();
if (!empty($result)) {
$select = & $this->stmtOptions['select'];
// handle selected key
if (!in_array('key', $select)) {
unset($result['key']);
}
// handle selected value
if (!in_array('value', $select)) {
unset($result['value']);
}
} else {
// clear stmt
$this->stmtActive = false;
$this->stmtOptions = null;
}
return $result;
}
示例3: fetch
/**
* Fetches the next item from result set
*
* @return array|boolean The next item or false
* @see fetchAll()
*
* @triggers fetch.pre(PreEvent)
* @triggers fetch.post(PostEvent)
* @triggers fetch.exception(ExceptionEvent)
*/
public function fetch()
{
if (!$this->stmtActive) {
return false;
}
$args = new ArrayObject();
try {
$eventRs = $this->triggerPre(__FUNCTION__, $args);
if ($eventRs->stopped()) {
return $eventRs->last();
}
$prefixL = strlen($this->stmtOptions['namespace'] . $this->getOptions()->getNamespaceSeparator());
if (!$this->stmtIterator) {
// clear stmt
$this->stmtActive = false;
$this->stmtIterator = null;
$this->stmtOptions = null;
$result = false;
} else {
$result = $this->memcached->fetch();
if (!empty($result)) {
$select = $this->stmtOptions['select'];
if (in_array('key', $select)) {
$result['key'] = substr($result['key'], $prefixL);
}
}
}
return $this->triggerPost(__FUNCTION__, $args, $result);
} catch (\Exception $e) {
return $this->triggerException(__FUNCTION__, $args, $e);
}
}
示例4: testGetDelayedSuccess
public function testGetDelayedSuccess()
{
$request = new MemcacheGetRequest();
$request->addKey("key");
$request->addKey("bar");
$request->setForCas(true);
$response = new MemcacheGetResponse();
$item = $response->addItem();
$item->setKey("key");
$item->setValue("value");
$item->setFlags(0);
// string.
$item->setCasId(123456);
$item = $response->addItem();
$item->setKey("bar");
$item->setValue("bar_value");
$item->setFlags(0);
// string.
$item->setCasId(2);
$cb_count = 0;
$cb = function ($val) use(&$cb_count) {
$cb_count++;
};
$this->apiProxyMock->expectCall('memcache', 'Get', $request, $response);
$memcached = new Memcached();
$this->assertTrue($memcached->getDelayed(["key", "bar"], true, $cb));
$this->assertEquals($memcached->getResultCode(), Memcached::RES_SUCCESS);
$result = $memcached->fetch();
$this->assertEquals($result["key"], "key");
$this->assertEquals($result["value"], "value");
$this->assertEquals($result["cas"], 123456);
$result = $memcached->fetch();
$this->assertEquals($result["key"], "bar");
$this->assertEquals($result["value"], "bar_value");
$this->assertEquals($result["cas"], 2);
$this->assertFalse($memcached->fetch());
$this->assertEquals($cb_count, 2);
$this->apiProxyMock->verify();
}
示例5: fetch
/**
* Fetch the next result.
*
* @link http://www.php.net/manual/en/memcached.fetch.php
*
* @return array|bool Returns the next result or FALSE on failure.
*/
public function fetch()
{
return $this->m->fetch();
}
示例6: Memcached
<?php
$m = new Memcached();
$m->addServer('127.0.0.1', 11211);
$m->set('foo', 'bar');
$m->set('foo2', 'bar2');
$m->getDelayed(array('foo', 'foo2'), true);
while ($result = $m->fetch()) {
var_dump($result);
}
示例7: fetch
/**
* Fetch the next result.
*
* @link http://www.php.net/manual/en/memcached.fetch.php
*
* @return array|bool Returns the next result or FALSE on failure.
*/
public function fetch()
{
return $this->daemon->fetch();
}