代潇瑞博客

hSetNx 命令/方法/函数

Adds a value to the hash stored at key only if this field isn't already in the hash.

添加一个VALUE到HASH STORE中,如果FIELD不存在。


Return value

BOOL TRUE if the field was set, FALSE if it was already present.


Example

$redis->delete('h')

$redis->hSetNx('h', 'key1', 'hello'); /* TRUE, 'key1' => 'hello' in the hash at "h" */

$redis->hSetNx('h', 'key1', 'world'); /* FALSE, 'key1' => 'hello' in the hash at "h". No change since the field wasn't replaced. */

【相关命令】

触屏版 | 电脑版

Copyright © 2013 代潇瑞博客手机版

QQ: 446673330

粤ICP备13071969号-1