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


PHP Client::mget方法代码示例

本文整理汇总了PHP中Predis\Client::mget方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::mget方法的具体用法?PHP Client::mget怎么用?PHP Client::mget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Predis\Client的用法示例。


在下文中一共展示了Client::mget方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTextsByUser

 /**
  * @param $hostUid
  * @param $key
  * @return null|UserText
  */
 public function getTextsByUser($hostUid, $cached = true)
 {
     if ($cached) {
         $pattern = $this->buildKey($hostUid, '*', '*');
         $prefix = $this->redis->getOptions()->prefix;
         $redisKeys = array_map(function ($redisKey) use($prefix) {
             if (substr($redisKey, 0, strlen($prefix)) == $prefix) {
                 $redisKey = substr($redisKey, strlen($prefix));
             }
             return $redisKey;
         }, $this->redis->keys($pattern));
         if (count($redisKeys) > 0) {
             $result = array_combine($redisKeys, $this->redis->mget($redisKeys));
             foreach ($result as $redisKey => $text) {
                 list(, , $userId, , $key, $lang) = explode(':', $redisKey);
                 $this->texts[$userId][$key][$lang] = $text;
             }
         }
     }
     if (!$cached || !isset($this->texts[$hostUid]) || !$this->texts[$hostUid]) {
         $this->texts[$hostUid] = $this->getTextsByHostFromMysql($hostUid);
         $mset = [];
         foreach ($this->texts[$hostUid] as $key => $langs) {
             foreach ($langs as $lang => $text) {
                 $mset[$this->buildKey($hostUid, $key, $lang)] = $text;
             }
         }
         if ($mset) {
             $this->redis->mset($mset);
         }
     }
     return $this->texts[$hostUid];
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:38,代码来源:DataProvider.php

示例2: getMany

 /**
  * Retrieves many item from the cache.
  *
  * @param array $keys
  *
  * @return mixed
  */
 public function getMany(array $keys) : array
 {
     // Retrieve all keys
     $items = $this->predis->mget(array_map(function ($key) {
         return $this->prefix . $key;
     }, $keys));
     // Unserialize items
     return array_map(function ($item) {
         return is_numeric($item) ? $item : unserialize($item);
     }, $items);
 }
开发者ID:domynation,项目名称:domynation-framework,代码行数:18,代码来源:RedisCache.php

示例3: 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->mget($keys);
     $rtn = [];
     // The Redis extension returns false not null for nonexistent
     // values. For consistency's sake, we spoof that here
     foreach ($keys as $index => $key) {
         $value = $values[$index];
         $rtn[$this->instance->unkey($key)] = $value;
     }
     return $rtn;
 }
开发者ID:molovo,项目名称:amnesia,代码行数:19,代码来源:Predis.php

示例4: get

 public function get($keys)
 {
     if (!$keys) {
         return [];
     }
     $keyValue = array_combine($keys, $this->redis->mget($keys));
     array_walk($keyValue, function (&$item) {
         $item = json_decode($item);
     });
     $keyValue = array_filter($keyValue, function ($value) {
         return !is_null($value);
     });
     return $keyValue;
 }
开发者ID:angejia,项目名称:pea,代码行数:14,代码来源:RedisCache.php

示例5: getStatusQueue

 function getStatusQueue()
 {
     //$iterator = new Iterator\Keyspace($this->redisClient, $this->taskListKey . "*", 2000);
     $iterator = new Iterator\Keyspace($this->redisClient, "*", 2000);
     //$iterator = new Iterator\Keyspace($this->redisClient, $this->statusKey . "*", 2000);
     $keys = [];
     foreach ($iterator as $key) {
         $keys[] = $key;
     }
     if (!count($keys)) {
         return [];
     }
     $values = $this->redisClient->mget($keys);
     return array_combine($keys, $values);
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:15,代码来源:RedisTaskQueue.php

示例6: multiRead

 public function multiRead($keys)
 {
     if ($prefix = $this->prefix) {
         $prefixed = array_map(function ($v) use($prefix) {
             return $prefix . $v;
         }, $keys);
     } else {
         $prefixed = $keys;
     }
     $values = $this->store->mget($prefixed);
     foreach ($values as &$v) {
         if ($v !== null) {
             $v = unserialize($v);
         }
     }
     return array_combine($keys, $values);
 }
开发者ID:simon-downes,项目名称:spf,代码行数:17,代码来源:Redis.php

示例7: getStates

 /**
  * @param string $namespace
  * @param array  $keys
  *
  * @return array
  */
 public function getStates($namespace, array $keys)
 {
     $values = [];
     $namespaceKeys = array_map(function ($key) use($namespace) {
         return $this->buildCurrentKey($this->buildNamespaceKey($namespace, $key));
     }, $keys);
     if (count($namespaceKeys) > 0) {
         $values = array_combine($keys, $this->redis->mget($namespaceKeys));
     }
     return $values;
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:17,代码来源:StateMachine.php

示例8: getQueueEntries

 private function getQueueEntries($keyStub)
 {
     $iterator = new Iterator\Keyspace($this->redisClient, $keyStub . "*", 2000);
     $keyList = [];
     foreach ($iterator as $key) {
         $keyList[] = $key;
     }
     if (!count($keyList)) {
         return [];
     }
     $values = $this->redisClient->mget($keyList);
     return array_combine($keyList, $values);
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:13,代码来源:RedisTaskQueue.php

示例9: getUsersFromRedis

 /**
  * @param $namespace
  * @param array $uids
  */
 protected function getUsersFromRedis($namespace, array $uids = [])
 {
     $users = [];
     $keys = array_map(function ($uid) use($namespace) {
         return 'users:' . $namespace . ':' . $uid;
     }, $uids);
     if (count($keys) > 0) {
         $data = $this->redis->mget($keys);
         foreach ($data as $serializedUserModel) {
             /** @var $userModel Model\User */
             if ($serializedUserModel) {
                 $userModel = unserialize($serializedUserModel);
                 $users[$userModel->getUid()] = $userModel;
             }
         }
     }
     return $users;
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:22,代码来源:AbstractDataProvider.php

示例10: read

 /**
  * {@inheritdoc}
  */
 protected function read(array $keys)
 {
     $values = $this->client->mget($keys);
     return array_combine($keys, $values);
 }
开发者ID:autocom,项目名称:smarty-redis,代码行数:8,代码来源:CacheResource.php


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