Node-redis: client.set expire

Created on 15 Feb 2019  ·  1Comment  ·  Source: NodeRedis/node-redis

I have been using the cache so far in this way

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);
            }); 

passing the EX, and setting a variable expressed in seconds.
I see from tests that it is used in a different way

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);
                });

Which is the correct way in the current version?

question

>All comments

Both are OK. This is independent from node_redis and just how Redis itself works. Please do not ask generic Redis questions here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yuany picture yuany  ·  4Comments

juriansluiman picture juriansluiman  ·  3Comments

dotSlashLu picture dotSlashLu  ·  5Comments

shmendo picture shmendo  ·  6Comments

Stono picture Stono  ·  6Comments