【发布时间】:2021-05-08 21:40:19
【问题描述】:
Redis 命令 HMSET 从版本 4 开始一直是deprecated。他们建议改用 HSET。但是,当我尝试这样做时,我会收到不同的弃用警告。
我使用的是:db.hmset('key', {a: 1, b: 'c'})。现在我尝试用db.hset 替换它,但这会触发:
node_redis: Deprecated: The HSET command contains a argument of type Object.
This is converted to "[object Object]" by using .toString() now and will return an error from v.3.0 on.
Please handle this in your code to make sure everything works as you intended it to.
在 Redis 数据库中存储对象的正确方法是什么?
Redis HSET 的文档指出:“从 Redis 4.0.0 开始,HSET 是可变参数并允许多个字段/值对。”我想存储整个对象,就像它在数据库中使用 hmset 一样,而不是它的字符串表示。
【问题讨论】:
标签: javascript node.js redis node-redis