代潇瑞博客

setnx 命令/方法/函数

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 */

【相关命令】

触屏版 | 电脑版

Copyright © 2013 代潇瑞博客手机版

QQ: 446673330

粤ICP备13071969号-1