Skip to content

Commit

Permalink
fix: callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Mar 15, 2019
1 parent f8fa659 commit b48b6d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/database/redis/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ module.exports = function (redisClient, module) {

module.getObjects = function (keys, callback) {
var cachedData = {};
function getFromCache() {
process.nextTick(callback, null, keys.map(key => _.clone(cachedData[key])));
function getFromCache(next) {
process.nextTick(next, null, keys.map(key => _.clone(cachedData[key])));
}

const unCachedKeys = cache.getUnCachedKeys(keys, cachedData);
if (!unCachedKeys.length) {
return getFromCache();
return getFromCache(callback);
}

async.waterfall([
Expand All @@ -86,7 +86,7 @@ module.exports = function (redisClient, module) {
cache.set(key, cachedData[key]);
});

getFromCache();
getFromCache(next);
},
], callback);
};
Expand Down
4 changes: 2 additions & 2 deletions src/groups/membership.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ module.exports = function (Groups) {

Groups.isMembers = function (uids, groupName, callback) {
var cachedData = {};
function getFromCache() {
setImmediate(callback, null, uids.map(uid => cachedData[uid + ':' + groupName]));
function getFromCache(next) {
setImmediate(next, null, uids.map(uid => cachedData[uid + ':' + groupName]));
}
if (!groupName || !uids.length) {
return setImmediate(callback, null, uids.map(() => false));
Expand Down

0 comments on commit b48b6d7

Please sign in to comment.