diff --git a/src/database/redis/hash.js b/src/database/redis/hash.js index 3a83b861fe..42a1fccffc 100644 --- a/src/database/redis/hash.js +++ b/src/database/redis/hash.js @@ -98,9 +98,7 @@ module.exports = function (module) { if (!Array.isArray(keys) || !keys.length) { return []; } - if (!Array.isArray(fields)) { - return keys.map(() => ({})); - } + const cachedData = {}; const unCachedKeys = cache.getUnCachedKeys(keys, cachedData); @@ -118,7 +116,7 @@ module.exports = function (module) { cache.set(key, cachedData[key]); }); - if (!fields.length) { + if (!Array.isArray(fields) || !fields.length) { return keys.map(key => (cachedData[key] ? { ...cachedData[key] } : null)); } return keys.map((key) => {