【发布时间】:2017-09-25 17:55:44
【问题描述】:
我是这个 redis 的新手,所以请帮助我! 我使用这个命令在redis中存储了值,
client.hmset('top_trend', array[0], 0);
client.expire('top_trend', 86400, redis.print);
如果我尝试使用此命令再次设置相同的键,我将增加值“0”,
if(client.hexists('top_trend', array[0]) == true){
client.hincrby('top_trend', array[0] , 1, redis.print);
}
这会将我的数据数组存储在 redis 中,例如, 例如:key = "top_trend"
"tamil"
"0"
"english"
"0"
"hindi"
"0"
如果泰米尔语已经可用于键“top_trend”,它将像这样递增其值:
"tamil"
"1"
"english" (//if english is already 3 times available)
"4"
现在我需要对值进行排序: 按降序排列并在节点 js 中按排序顺序获取值。如何实现它。?我尝试通过 object_*->object 命令对 key_value 进行排序,如下所示。但它不会起作用。帮帮我。
【问题讨论】:
标签: javascript node.js sorting redis node-redis