如果尚未使用Expire命令的NX选项设置到期,我将尝试在密钥上设置到期。
但我不断从reds-cli中得到错误,当我从代码中尝试时,NX选项被忽略。
当我尝试使用redis cli中的Expire命令时,我会收到以下错误
127.0.0.1:6379> expire ns1 500 NX
(error) ERR wrong number of arguments for 'expire' command
Redis版本-v=6.2.6
另外,如果我尝试用程序进行操作,expire命令将被忽略。以下代码-
let res = await client.INCRBY('ns1', 5)
console.log('incr val ' + res)
res = await client.EXPIRE('ns1', 60, { 'NX': true }) // this should set expiry
res = await client.EXPIRE('ns1', 180, { 'NX': true }) //this should ignore setting expiry
res = await client.TTL('ns1')console.log('ttl expiry ' + res)`
我得到的回复是
incr val 5
ttl expiry 180
任何解决这一问题的帮助都将是伟大的
感谢
https://www.redis.io/commands/expire"从Redis 7.0.0版本开始:添加选项:NX
、XX
、GT
和LT
";