NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
## 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*`<span class="calibre12">TRUE</span>` in case of success, `<span class="calibre12">FALSE</span>` in case of failure. ##### Examples ``` <pre class="calibre9">$redis->setnx('key', 'value'); /* return TRUE */ $redis->setnx('key', 'value'); /* return FALSE */ ```