示例#1
0
 /**
  * Sets multiple key-value pairs in one atomic command.
  * MSETNX only returns TRUE if all the keys were set (see SETNX).
  *
  * @param array $array Pairs: array(key => value, ...)
  *
  * @return bool TRUE in case of success, FALSE in case of failure.
  * @link http://redis.io/commands/mset
  * @example
  * <pre>
  * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
  * var_dump($redis->get('key0'));
  * var_dump($redis->get('key1'));
  * // Output:
  * // string(6) "value0"
  * // string(6) "value1"
  * </pre>
  */
 public function mSet(array $array)
 {
     try {
         return $this->client->mSet($array);
     } catch (Exception $e) {
         return $this->handleException($e, __FUNCTION__, func_get_args());
     }
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function mSet(array $array)
 {
     $cachedValues = array();
     foreach ($array as $key => $value) {
         $entry = array('value' => $value, 'cached_at' => $this->time->current(), 'ttl' => $this->lifetime);
         $this->cache[$key] = $entry;
         $cachedValues[$key] = $value;
     }
     $this->redis->mSet($cachedValues);
 }
示例#3
0
 /**
  * Sets multiple key-value pairs in one atomic command.
  * MSETNX only returns TRUE if all the keys were set (see SETNX).
  *
  * @param array $array Pairs: array(key => value, ...)
  *
  * @return bool TRUE in case of success, FALSE in case of failure.
  * @link http://redis.io/commands/mset
  * @example
  * <pre>
  * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
  * var_dump($redis->get('key0'));
  * var_dump($redis->get('key1'));
  * // Output:
  * // string(6) "value0"
  * // string(6) "value1"
  * </pre>
  */
 public function mSet(array $array)
 {
     $this->appendToLog('MSET ' . implode(' ', $array));
     return $this->client->mSet($array);
 }