redis时间排序,内容显示
redis时间排序,内容显示
global.redisRelation.set("msg_time:1:time","2032-5-3 06:26:08");
global.redisRelation.set("msg_time:2:time","2002-5-3 14:26:08");
global.redisRelation.set("msg_time:3:time","2030-5-3 03:26:08");
global.redisRelation.set("msg_time:4:time","2030-5-3 03:26:07");
global.redisRelation.set("msgcontent:1",JSON.stringify({content:"44"}));
global.redisRelation.set("msgcontent:2",JSON.stringify({content:"bb"}));
global.redisRelation.set("msgcontent:3",JSON.stringify({content:"aa"}));
global.redisRelation.set("msgcontent:4",JSON.stringify({content:"55"}));
global.redisRelation.sort("msg","by","msg_time:*:time","desc",
"alpha","get","msgcontent:*","store","tmp");
"alpha","get","msgcontent:*","store","tmp");
global.redisRelation.lrange("tmp",0,-1,function(err,values){
console.log("易做图");
for(var i=0;i
{
var obj=JSON.parse(values[i]);
console.log(obj.content);
}
});
根据msg_time:*:time的时间对msgcontent:*中的内容取出,放入tmp中