mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
late night optimizations
-isMemberOfSets returns true/false instead of 1/0 -when loading the posts of a topic only get the userdata for each user once, before this commit if a topic had 10 posts from 2 different users we were getting the user data for each user 5 times (drunk) -getVoteStatusByPostIDs and getFavouritesByPostIDs no longer make pids.length calls to the db, they use isMemberOfSets now -getUserInfoForPost renamed to getUserInfoForPosts and doesnt make uids.length calls to db, uses getMultipleUserFields instead
This commit is contained in:
@@ -40,11 +40,20 @@ module.exports = function(redisClient, module) {
|
||||
module.isMemberOfSets = function(sets, value, callback) {
|
||||
var multi = redisClient.multi();
|
||||
|
||||
for (var i = 0, ii = sets.length; i < ii; i++) {
|
||||
for (var i = 0; i < sets.length; ++i) {
|
||||
multi.sismember(sets[i], value);
|
||||
}
|
||||
|
||||
multi.exec(callback);
|
||||
multi.exec(function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
for (var i=0; i<results.length; ++i) {
|
||||
results[i] = results[i] === 1;
|
||||
}
|
||||
callback(null, results);
|
||||
});
|
||||
};
|
||||
|
||||
module.getSetMembers = function(key, callback) {
|
||||
|
||||
Reference in New Issue
Block a user