获取 redis 过期的价值 - nodejs

时间:2020-12-28 12:49:37

标签: javascript node.js redis

我在 nodejs 中使用 Redis,当某些东西过期时,我使用以下代码来通知:

module.exports.expire = (callback) => {
    const expired = () => {
        const sub = redis.createClient({url: redisPath})
        sub.subscribe('__keyevent@0__:expired', () => {
            sub.on('message', (channel, message) => {
                callback(message)
        })
    })
}

 const pub = redis.createClient({ url: redisPath })
 pub.send_command('config', ['set', 'notify-keyspace-events' , 'Ex'], expired())
}

当某些东西过期时,我会收到事件但只有键而不是值。有谁知道在某些内容过期时获取键 + 值的方法。

谢谢

0 个答案:

没有答案
相关问题