Description
Set the string value in argument as value of the key if the key doesn't already exist in the database.
setnx用于设置一个KEY-VALUE,这个函数会先判断Redis中是否有这个KEY,如果没有就SET,有就返回False。
Parameters
key value
Return value
Bool TRUE in case of success, FALSE in case of failure.
Examples
$redis->setnx('key', 'value'); /* return TRUE */
$redis->setnx('key', 'value'); /* return FALSE */