当前位置: 首页>>代码示例>>PHP>>正文


PHP Memcached::fetch方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:ranxin1022,项目名称:zf2,代码行数:42,代码来源:Memcached.php

示例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;
    }
开发者ID:necrogami,项目名称:zf2,代码行数:34,代码来源:Memcached.php

示例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);
     }
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:42,代码来源:Memcached.php

示例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();
 }
开发者ID:spudder-com,项目名称:spudder-django,代码行数:39,代码来源:MemcachedTest.php

示例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();
 }
开发者ID:AlwaysOnline,项目名称:wordpress-pecl-memcached-object-cache,代码行数:11,代码来源:object-cache.php

示例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);
}
开发者ID:GrUSP,项目名称:php_best_practices,代码行数:10,代码来源:memcached_fetch.php

示例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();
 }
开发者ID:benediktharter,项目名称:wp-spider-cache,代码行数:11,代码来源:class-object-cache.php


注:本文中的Memcached::fetch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。