hSet 命令/方法/函数

Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned.

添加一个VALUE到HASH中。如果VALUE已经存在于HASH中,则返回FALSE。


Parameters

key

hashKey

value


Return value

LONG 1 if value didn't exist and was added successfully, 0 if the value was already present and was replaced, FALSE if there was an error.


Example

$redis->delete('h')

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

$redis->hGet('h', 'key1'); /* returns "hello" */


$redis->hSet('h', 'key1', 'plop'); /* 0, value was replaced. */

$redis->hGet('h', 'key1'); /* returns "plop" */