mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
fix: callbacks
This commit is contained in:
@@ -63,13 +63,13 @@ module.exports = function (redisClient, module) {
|
|||||||
|
|
||||||
module.getObjects = function (keys, callback) {
|
module.getObjects = function (keys, callback) {
|
||||||
var cachedData = {};
|
var cachedData = {};
|
||||||
function getFromCache() {
|
function getFromCache(next) {
|
||||||
process.nextTick(callback, null, keys.map(key => _.clone(cachedData[key])));
|
process.nextTick(next, null, keys.map(key => _.clone(cachedData[key])));
|
||||||
}
|
}
|
||||||
|
|
||||||
const unCachedKeys = cache.getUnCachedKeys(keys, cachedData);
|
const unCachedKeys = cache.getUnCachedKeys(keys, cachedData);
|
||||||
if (!unCachedKeys.length) {
|
if (!unCachedKeys.length) {
|
||||||
return getFromCache();
|
return getFromCache(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
@@ -86,7 +86,7 @@ module.exports = function (redisClient, module) {
|
|||||||
cache.set(key, cachedData[key]);
|
cache.set(key, cachedData[key]);
|
||||||
});
|
});
|
||||||
|
|
||||||
getFromCache();
|
getFromCache(next);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -162,8 +162,8 @@ module.exports = function (Groups) {
|
|||||||
|
|
||||||
Groups.isMembers = function (uids, groupName, callback) {
|
Groups.isMembers = function (uids, groupName, callback) {
|
||||||
var cachedData = {};
|
var cachedData = {};
|
||||||
function getFromCache() {
|
function getFromCache(next) {
|
||||||
setImmediate(callback, null, uids.map(uid => cachedData[uid + ':' + groupName]));
|
setImmediate(next, null, uids.map(uid => cachedData[uid + ':' + groupName]));
|
||||||
}
|
}
|
||||||
if (!groupName || !uids.length) {
|
if (!groupName || !uids.length) {
|
||||||
return setImmediate(callback, null, uids.map(() => false));
|
return setImmediate(callback, null, uids.map(() => false));
|
||||||
|
|||||||
Reference in New Issue
Block a user