Example #1
0
 /**
  * Renames a key.
  * Same as rename, but will not replace a key if the destination already exists.
  * This is the same behaviour as setNx.
  *
  * @param string $srcKey
  * @param string $dstKey
  *
  * @return bool: TRUE in case of success, FALSE in case of failure.
  * @link http://redis.io/commands/renamenx
  * @example
  * <pre>
  * $redis->set('x', '42');
  * $redis->rename('x', 'y');
  * $redis->get('y'); // → 42
  * $redis->get('x'); // → `FALSE`
  * </pre>
  */
 public function renameNx($srcKey, $dstKey)
 {
     try {
         return $this->client->renameNx($srcKey, $dstKey);
     } catch (Exception $e) {
         return $this->handleException($e, __FUNCTION__, func_get_args());
     }
 }
Example #2
0
 /**
  * Renames a key.
  * Same as rename, but will not replace a key if the destination already exists.
  * This is the same behaviour as setNx.
  *
  * @param string $srcKey
  * @param string $dstKey
  * @throws IdenticalSourceDestinationException
  *
  * @return bool: TRUE in case of success, FALSE in case of failure.
  * @link http://redis.io/commands/renamenx
  * @example
  * <pre>
  * $redis->set('x', '42');
  * $redis->rename('x', 'y');
  * $redis->get('y'); // → 42
  * $redis->get('x'); // → `FALSE`
  * </pre>
  */
 public function renameNx($srcKey, $dstKey)
 {
     $this->appendToLog('RENAMENX ' . $srcKey . ' ' . $dstKey);
     return $this->client->renameNx($srcKey, $dstKey);
 }