Node-redis: client.set过期

创建于 2019-02-15  ·  1评论  ·  资料来源: NodeRedis/node-redis

到目前为止,我一直以这种方式使用缓存

self.client.set(key, value, 'EX', _expire, function(err, res) {
                // res is null when the key is missing
                if(err) self.logger.error("RedisStore.set err %@", err);
                else self.logger.debug("RedisStore.set %@", key);
                return callback(err, res);
            }); 

传递EX ,并设置以秒表示的变量。
我从测试中看到它以不同的方式使用

client.set(['ttl key', 'ttl val'], helper.isString('OK'));
                client.expire(['ttl key', '100'], helper.isNumber(1));
                client.TTL(['ttl key'], function (err, ttl) {
                    assert(ttl >= 99);
                    assert(ttl <= 100);
                    done(err);
                });

当前版本中正确的方法是哪种?

question

>所有评论

都可以。 这与node_redis以及Redis本身的工作方式无关。 请不要在这里问通用Redis问题。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

Alchemystic picture Alchemystic  ·  6评论

adamgajzlerowicz picture adamgajzlerowicz  ·  4评论

Atala picture Atala  ·  3评论

jackycchen picture jackycchen  ·  4评论

id0Sch picture id0Sch  ·  4评论