Example #1
0
 /**
  * Returns the values of all specified keys.
  * For every key that does not hold a string value or does not exist,
  * the special value false is returned. Because of this, the operation never fails.
  *
  * @param array $array
  *
  * @return array
  * @link http://redis.io/commands/mget
  * @example
  * <pre>
  * $redis->delete('x', 'y', 'z', 'h');        // remove x y z
  * $redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'));
  * $redis->hset('h', 'field', 'value');
  * var_dump($redis->mget(array('x', 'y', 'z', 'h')));
  * // Output:
  * // array(3) {
  * // [0]=>
  * // string(1) "a"
  * // [1]=>
  * // string(1) "b"
  * // [2]=>
  * // string(1) "c"
  * // [3]=>
  * // bool(false)
  * // }
  * </pre>
  */
 public function mGet(array $array)
 {
     try {
         return $this->client->mGet($array);
     } catch (Exception $e) {
         return $this->handleException($e, __FUNCTION__, func_get_args());
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function mGet(array $array)
 {
     $result = array();
     $uncachedKeys = array();
     $position = 0;
     foreach ($array as $key) {
         if ($this->hasValidCacheEntry($key)) {
             $result[$position] = $this->cache[$key]['value'];
         } else {
             $uncachedKeys[$key] = $position;
         }
         $position++;
     }
     if (!empty($uncachedKeys)) {
         $values = $this->redis->mGet(array_keys($uncachedKeys));
         foreach ($uncachedKeys as $position) {
             $result[$position] = array_shift($values);
         }
     }
     return $result;
 }
Example #3
0
 /**
  * Returns the values of all specified keys.
  * For every key that does not hold a string value or does not exist,
  * the special value false is returned. Because of this, the operation never fails.
  *
  * @param array $array
  *
  * @return array
  * @link http://redis.io/commands/mget
  * @example
  * <pre>
  * $redis->delete('x', 'y', 'z', 'h');        // remove x y z
  * $redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'));
  * $redis->hset('h', 'field', 'value');
  * var_dump($redis->mget(array('x', 'y', 'z', 'h')));
  * // Output:
  * // array(3) {
  * // [0]=>
  * // string(1) "a"
  * // [1]=>
  * // string(1) "b"
  * // [2]=>
  * // string(1) "c"
  * // [3]=>
  * // bool(false)
  * // }
  * </pre>
  */
 public function mGet(array $array)
 {
     $this->appendToLog('MGET ' . implode(' ', $array));
     return $this->client->mGet($array);
 }