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

>すべてのコメント

どちらもOKです。 これは、node_redisや、Redis自体の動作とは無関係です。 ここで一般的なRedisの質問をしないでください。

このページは役に立ちましたか?
0 / 5 - 0 評価

関連する問題

Atala picture Atala  ·  3コメント

Mickael-van-der-Beek picture Mickael-van-der-Beek  ·  6コメント

Stono picture Stono  ·  6コメント

id0Sch picture id0Sch  ·  4コメント

ghost picture ghost  ·  3コメント