解决方法
这段代码看起来不错.查看以下链接以检索您想要的内容:
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();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。