Example #1
0
 /**
  * Set the string value in argument as value of the key if the key doesn't already exist in the database.
  *
  * @param string $key
  * @param string $value
  *
  * @return bool: TRUE in case of success, FALSE in case of failure.
  * @link http://redis.io/commands/setnx
  * @example
  * <pre>
  * $redis->setnx('key', 'value'); // return TRUE
  * $redis->setnx('key', 'value'); // return FALSE
  * </pre>
  */
 public function setNx($key, $value)
 {
     try {
         return $this->client->setNx($key, $value);
     } catch (Exception $e) {
         return $this->handleException($e, __FUNCTION__, func_get_args());
     }
 }
Example #2
0
 /**
  * Set the string value in argument as value of the key if the key doesn't already exist in the database.
  *
  * @param string $key
  * @param string $value
  *
  * @return bool: TRUE in case of success, FALSE in case of failure.
  * @link http://redis.io/commands/setnx
  * @example
  * <pre>
  * $redis->setnx('key', 'value'); // return TRUE
  * $redis->setnx('key', 'value'); // return FALSE
  * </pre>
  */
 public function setNx($key, $value)
 {
     $this->appendToLog('SETNX ' . $key . ' ' . $value);
     return $this->client->setNx($key, $value);
 }