【发布时间】:2022-02-01 07:28:59
【问题描述】:
我正在使用带有节点的 redis (v 3.1.2) 并尝试设置一个带有过期时间的哈希键,我一直坚持在哪里为过期命令提供这个附加属性 (NX/XX/GT/LT) 的部分.
await client.hset(hashKey, key, JSON.stringify(value));
await client.expire(hashKey,expire)
有人可以帮忙吗?
【问题讨论】:
我正在使用带有节点的 redis (v 3.1.2) 并尝试设置一个带有过期时间的哈希键,我一直坚持在哪里为过期命令提供这个附加属性 (NX/XX/GT/LT) 的部分.
await client.hset(hashKey, key, JSON.stringify(value));
await client.expire(hashKey,expire)
有人可以帮忙吗?
【问题讨论】:
只需将第三个参数传递给 expire 方法:
client.expire(hashKey, expire, 'NX');
【讨论】: