當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Memcached::getMulti方法代碼示例

本文整理匯總了PHP中Memcached::getMulti方法的典型用法代碼示例。如果您正苦於以下問題:PHP Memcached::getMulti方法的具體用法?PHP Memcached::getMulti怎麽用?PHP Memcached::getMulti使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Memcached的用法示例。


在下文中一共展示了Memcached::getMulti方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: multiGet

 /**
  * @param string[] $keys
  * @return mixed[]
  */
 public function multiGet(string ...$keys) : array
 {
     if (count($keys) === 0) {
         return [];
     }
     return $this->client->getMulti($keys);
 }
開發者ID:lizards-and-pumpkins,項目名稱:lib-key-value-store-memcached,代碼行數:11,代碼來源:MemcachedKeyValueStore.php

示例2: getMulti

 /**
  * {@inheritdoc}
  */
 public function getMulti(array $keys, array &$tokens = null)
 {
     $return = $this->client->getMulti($keys, $tokens);
     // HHVMs getMulti() returns null instead of empty array for no results,
     // so normalize that
     $tokens = $tokens ?: array();
     return $return ?: array();
 }
開發者ID:Nyholm,項目名稱:scrapbook,代碼行數:11,代碼來源:Memcached.php

示例3: getArrayDataFromStorage

 /**
  * {@inheritdoc}
  */
 protected function getArrayDataFromStorage(array $keys)
 {
     $result = $this->memcached->getMulti($keys);
     if ($result === false) {
         return [];
     }
     return $result;
 }
開發者ID:tlumx,項目名稱:framework,代碼行數:11,代碼來源:MemcachedCachePool.php

示例4: multiRead

 public function multiRead($keys)
 {
     $cas = null;
     $values = $this->store->getMulti($keys, $cas, Memcached::GET_PRESERVE_ORDER);
     if (!$values) {
         $values = array_fill_keys($keys, null);
     }
     return $values;
 }
開發者ID:simon-downes,項目名稱:spf,代碼行數:9,代碼來源:Memcache.php

示例5: read

 /**
  * Read values for a set of keys from cache
  *
  * @param  array $keys list of keys to fetch
  *
  * @return array   list of values with the given keys used as indexes
  * @return boolean true on success, false on failure
  */
 protected function read(array $keys)
 {
     $_keys = $lookup = [];
     list($_keys, $lookup) = $this->eachKeys($keys, $_keys, $lookup);
     $_res = [];
     $res = $this->memcached->getMulti($_keys);
     foreach ($res as $k => $v) {
         $_res[$lookup[$k]] = $v;
     }
     return $_res;
 }
開發者ID:shinichi81,項目名稱:Laravel.Smarty,代碼行數:19,代碼來源:Memcached.php

示例6: many

 /**
  * Retrieve multiple items from the cache by key.
  *
  * Items not found in the cache will have a null value.
  *
  * @param  array  $keys
  * @return array
  */
 public function many(array $keys)
 {
     $prefixedKeys = array_map(function ($key) {
         return $this->prefix . $key;
     }, $keys);
     $values = $this->memcached->getMulti($prefixedKeys, null, Memcached::GET_PRESERVE_ORDER);
     if ($this->memcached->getResultCode() != 0) {
         return array_fill_keys($keys, null);
     }
     return array_combine($keys, $values);
 }
開發者ID:quangtruong16994,項目名稱:laravel,代碼行數:19,代碼來源:MemcachedStore.php

示例7: getMulti

 /**
  * {@inheritdoc}
  */
 public function getMulti(array $keys, array &$tokens = null)
 {
     $keys = array_map(array($this, 'encodeKey'), $keys);
     $return = $this->client->getMulti($keys, $tokens);
     $keys = array_map(array($this, 'decodeKey'), array_keys($return));
     $return = array_combine($keys, $return);
     // HHVMs getMulti() returns null instead of empty array for no results,
     // so normalize that
     $tokens = $tokens ?: array();
     $tokens = array_combine($keys, $tokens);
     return $return ?: array();
 }
開發者ID:sternt,項目名稱:scrapbook,代碼行數:15,代碼來源:Memcached.php

示例8: getMulti

 /**
  * 獲取多條數據記錄
  * @param array $keys
  * @return mixed
  */
 public function getMulti(array $keys)
 {
     //保證返回的key的順序和請求時一致
     $data = $this->dbh->getMulti($keys, $cas, \Memcached::GET_PRESERVE_ORDER);
     if ($data === false) {
         if ($this->dbh->getResultCode() == \Memcached::RES_NOTFOUND) {
             return array();
         } else {
             $this->error('getMulti', json_encode($keys));
         }
     }
     return $data;
 }
開發者ID:songsihan,項目名稱:simple,代碼行數:18,代碼來源:NoSQL.php

示例9: mget

 /**
  * Get multiple values from the cache.
  *
  * @param array $keys An array of keys to get
  *
  * @return array An array of JSON objects
  */
 public function mget(array $keys = array())
 {
     $values = $this->client->getMulti($keys);
     $rtn = [];
     // The Memcached extension returns false not null for nonexistent
     // values. For consistency's sake, we spoof that here
     foreach ($keys as $key) {
         if (!isset($values[$key]) || $values[$key] === false) {
             $values[$key] = null;
         }
         $rtn[$this->instance->unkey($key)] = $values[$key];
     }
     return $rtn;
 }
開發者ID:molovo,項目名稱:amnesia,代碼行數:21,代碼來源:Memcached.php

示例10: getMulti

 public function getMulti($keys)
 {
     $result = new MultiGetResult($keys);
     $null = null;
     $cached = $this->memcached->getMulti(array_keys($keys), $null, \Memcached::GET_PRESERVE_ORDER);
     foreach ($cached as $key => $value) {
         if (null === $value) {
             $id = $keys[$key];
             $result->miss($id, $key);
         } else {
             $result->hit($key, $value);
         }
     }
     return $result;
 }
開發者ID:wucdbm,項目名稱:wucdbm-bundle,代碼行數:15,代碼來源:MemcachedStorage.php

示例11: getItems

 /**
  * Get multiple items.
  *
  * Options:
  *  - ttl <float> optional
  *    - The time-to-life (Default: ttl of object)
  *  - namespace <string> optional
  *    - The namespace to use (Default: namespace of object)
  *
  * @param  array $keys
  * @param  array $options
  * @return array Assoziative array of existing keys and values or false on failure
  * @throws Exception
  *
  * @triggers getItems.pre(PreEvent)
  * @triggers getItems.post(PostEvent)
  * @triggers getItems.exception(ExceptionEvent)
  */
 public function getItems(array $keys, array $options = array())
 {
     $baseOptions = $this->getOptions();
     if (!$baseOptions->getReadable()) {
         return array();
     }
     $this->normalizeOptions($options);
     $args = new ArrayObject(array('keys' => &$keys, 'options' => &$options));
     try {
         $eventRs = $this->triggerPre(__FUNCTION__, $args);
         if ($eventRs->stopped()) {
             return $eventRs->last();
         }
         $namespaceSep = $baseOptions->getNamespaceSeparator();
         $internalKeys = array();
         foreach ($keys as $key) {
             $internalKeys[] = $options['namespace'] . $namespaceSep . $key;
         }
         $fetch = $this->memcached->getMulti($internalKeys);
         if ($fetch === false) {
             throw new Exception\ItemNotFoundException('Memcached::getMulti(<array>) failed');
         }
         // remove namespace prefix
         $prefixL = strlen($options['namespace'] . $namespaceSep);
         $result = array();
         foreach ($fetch as $internalKey => &$value) {
             $result[substr($internalKey, $prefixL)] = $value;
         }
         return $this->triggerPost(__FUNCTION__, $args, $result);
     } catch (\Exception $e) {
         return $this->triggerException(__FUNCTION__, $args, $e);
     }
 }
開發者ID:nevvermind,項目名稱:zf2,代碼行數:51,代碼來源:Memcached.php

示例12: get

 /**
  * @Name get 根據鍵名獲取值
  *
  * @param string $key key
  * @return array OR json object OR string...
  *         add by cheng.yafei
  *
  */
 public function get($key = NULL)
 {
     if ($this->m) {
         $keyName = $this->key_name($key);
         if (isset($this->local_cache[$keyName])) {
             return $this->local_cache[$keyName];
         }
         if (is_null($key)) {
             $this->errors[] = 'The key value cannot be NULL';
             return false;
         }
         if (is_array($key)) {
             foreach ($key as $n => $k) {
                 $key[$n] = $this->key_name($k);
             }
             return $this->m->getMulti($key);
         } else {
             $obj = $this->m->get($keyName);
             $this->local_cache[$keyName] = $obj;
             return $obj;
         }
     } else {
         return false;
     }
 }
開發者ID:babety,項目名稱:HellaEngine,代碼行數:33,代碼來源:Memcached.php

示例13: read

 /**
  * Read cached data
  *
  * @param array $keys array of keys to load
  * @return array key/value cached data
  */
 protected function read(array $keys)
 {
     $keymap = array();
     $hashedkeys = array();
     foreach ($keys as $key) {
         $newkey = sha1($key);
         $keymap[$newkey] = $key;
         $hashedkeys[] = $newkey;
     }
     $data = false;
     $cachedata = array();
     if ($this->memcacheType == GitPHP_CacheResource_Memcache::Memcache) {
         $cachedata = $this->memcacheObj->get($hashedkeys);
     } else {
         if ($this->memcacheType == GitPHP_CacheResource_Memcache::Memcached) {
             $cachedata = $this->memcacheObj->getMulti($hashedkeys);
         }
     }
     if ($cachedata) {
         foreach ($cachedata as $key => $value) {
             $origkey = $keymap[$key];
             if (!empty($origkey)) {
                 $data[$origkey] = $value;
             }
         }
     }
     return $data;
 }
開發者ID:fboender,項目名稱:gitphp,代碼行數:34,代碼來源:CacheResource_Memcache.class.php

示例14: getCounters

 public function getCounters()
 {
     $counters = array();
     $result = $this->memcache->getMulti(array($this->prefix . 'hit', $this->prefix . 'miss', $this->prefix . 'error'));
     $counters['hit'] = array_key_exists($this->prefix . 'hit', $result) ? $result[$this->prefix . 'hit'] : 0;
     $counters['miss'] = array_key_exists($this->prefix . 'miss', $result) ? $result[$this->prefix . 'miss'] : 0;
     $counters['error'] = array_key_exists($this->prefix . 'error', $result) ? $result[$this->prefix . 'error'] : 0;
     $counters['age'] = $this->getReportAge();
     return $counters;
 }
開發者ID:ikkiChung,項目名稱:RESS,代碼行數:10,代碼來源:Memcached.php

示例15: internalGetMetadatas

 /**
  * Get metadata of multiple items
  *
  * Options:
  *  - namespace <string> optional
  *    - The namespace to use
  *
  * @param  array $normalizedKeys
  * @param  array $normalizedOptions
  * @return array
  * @throws Exception\ExceptionInterface
  *
  * @triggers getMetadatas.pre(PreEvent)
  * @triggers getMetadatas.post(PostEvent)
  * @triggers getMetadatas.exception(ExceptionEvent)
  */
 protected function internalGetMetadatas(array &$normalizedKeys, array &$normalizedOptions)
 {
     $this->memcached->setOption(MemcachedResource::OPT_PREFIX_KEY, $normalizedOptions['namespace']);
     $result = $this->memcached->getMulti($normalizedKeys);
     if ($result === false) {
         throw $this->getExceptionByResultCode($this->memcached->getResultCode());
     }
     foreach ($result as $key => &$value) {
         $value = array();
     }
     return $result;
 }
開發者ID:brikou,項目名稱:zend_cache,代碼行數:28,代碼來源:Memcached.php


注:本文中的Memcached::getMulti方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。