Redis lpop函数返回true而不是原始值

iq0todco  于 5个月前  发布在  Redis
关注(0)|答案(1)|浏览(76)

我有一个唯一的字符串列表,我需要根据用户弹出,所以我使用redis的lpop来做到这一点,问题是当试图从散列值中lpop时,返回true,并且项目正在被删除,但它不是作为值(原始值)返回,而是作为true返回。
列表不为空,Redis连接正在工作。
“redis”:“^2.8.0”,

export async function LPOP(hashKey, initialSource, fromWhere) {
    try {
        let redis = initialSource[fromWhere];

        const result = await redis.lpop([hashKey]);

        if (result) {
            return JSON.parse(result);
        }

        return result;
    } catch (err) {
        throw err;
    }
}

字符串

wlzqhblo

wlzqhblo1#

Node Redis 2.8.0已经非常非常老了。它不支持Promises-你正在使用的。这可能是你错误的核心。我建议你升级到最新版本:

const result = await client.lPop(key)

字符串
或者使用较旧的语法:

client.lpop(key, function(err, result) {
  // do something with the result
})

相关问题