SET key value 例如,将键 “name” 的值更新为 “John Doe”:
SET name "John Doe" ZADD key score member 例如,将有序集合 “my_sorted_set” 中成员 “member1” 的分数更新为 100:
ZADD my_sorted_set 100 member1 HSET key field value 例如,将哈希表 “my_hash” 中字段 “field1” 的值更新为 “newValue1”:
HSET my_hash field1 "newValue1" HSET 命令的多个参数形式:HSET key field1 value1 field2 value2 ... 例如,将哈希表 “my_hash” 中的字段 “field1” 更新为 “newValue1”,字段 “field2” 更新为 “newValue2”:
HSET my_hash field1 "newValue1" field2 "newValue2" HMSET 命令一次性更新哈希表中的多个字段:HMSET key field1 value1 field2 value2 ... 例如,将哈希表 “my_hash” 中的字段 “field1” 更新为 “newValue1”,字段 “field2” 更新为 “newValue2”:
HMSET my_hash field1 "newValue1" field2 "newValue2" 请注意,这些命令会覆盖原有的值。如果需要追加值而不是覆盖,请使用相应的命令,如 INCR、ZADD 或 HSET。