Node js和Redis根据条件过滤数据

时间:2021-02-14 15:46:44

标签: node.js redis node-redis

我在 redis 中将我的数据设置为这样的键值对

let data = [{key: 'a-9' , val: 'a'}, {key: 'a-7', val: 'b'}, {key: 'b-8', val: 'c'}]

并希望根据这样的条件取回数据

所有大于或等于 9 的 'a' 键

client.hgetAsync("class_cache", "a").then(res => {
    callback(null, res);               
}).catch(err => {
    console.error(err)
}).finally(() => {
    client.quit();
});

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

那是不可能的。仅检查模式中的 glob 是否匹配。支持的模式与用于 KEYS 命令的模式相同,如下所述:http://redis.io/commands/keys

您可以获取对象表单数据,并使用javascript命令处理对象

end
相关问题