解决方法
这段代码看起来不错.查看以下链接以检索您想要的内容:
http://ricochen.wordpress.com/2012/02/28/example-sorted-set-functions-with-node-js-redis/
var rc=require('redis').createClient(); var _=require('underscore'); rc.zincrby('myset',1,'usera'); rc.zincrby('myset',5,'userb'); rc.zincrby('myset',3,'userc'); rc.zrevrange('myset','withscores',members) { // the resulting members would be something like // ['userb','5','userc','3','usera','1'] // use the following trick to convert to // [ [ 'userb','5' ],[ 'userc','3' ],[ 'usera','1' ] ] // learned the trick from // https://stackoverflow.com/questions/8566667/split-javascript-array-in-chunks-using-underscore-js var lists=_.groupBy(members,function(a,b) { return Math.floor(b/2); }); console.log( _.toArray(lists) ); }); rc.quit();