Skip to content

Commit

Permalink
Merge pull request #23 from gechols/patch-1
Browse files Browse the repository at this point in the history
Added error check
  • Loading branch information
jpodwys authored Jul 1, 2020
2 parents 2cba5e6 + 6f10ceb commit ff44f83
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions redisCacheModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,18 @@ function redisCacheModule(config){
var cacheKeys = keys.map(prefixKey);
self.db.mget(cacheKeys, function (err, response){
var obj = {};
for(var i = 0; i < response.length; i++){
if(response[i] !== null){
try {
response[i] = self.JSON.parse(response[i]);
} catch (err) {
if(self.logJsonParseFailures) {
log(true, 'Error parsing JSON, err:', err);
if(!err && response) {
for(var i = 0; i < response.length; i++){
if(response[i] !== null){
try {
response[i] = self.JSON.parse(response[i]);
} catch (err) {
if(self.logJsonParseFailures) {
log(true, 'Error parsing JSON, err:', err);
}
}
obj[keys[i]] = response[i];
}
obj[keys[i]] = response[i];
}
}
cb(err, obj, index);
Expand Down Expand Up @@ -396,4 +398,4 @@ function redisCacheModule(config){
}

module.exports = redisCacheModule;
redisCacheModule._retryStrategy = retryStrategy;
redisCacheModule._retryStrategy = retryStrategy;

0 comments on commit ff44f83

Please sign in to comment.