當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。