Skip to content

Commit

Permalink
Merge pull request #165 from lbayas/master
Browse files Browse the repository at this point in the history
return an array of matching keys instead of an object
  • Loading branch information
joshuaslate authored Apr 19, 2020
2 parents 8052f31 + 8083c2d commit 4cbd96e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/adapters/RedisAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ export class RedisAdapter implements CacheClient {
}
};

static responseScanCommandCallback = (resolve: Function, reject: Function): Callback<any> => (
err: any,
response: any,
) => {
if (err) {
reject(err);
} else {
// array exists at index '1' from SCAN command
resolve(response['1']);
return;
}
};

// The node_redis client
private redisClient: RedisClient;

Expand Down Expand Up @@ -264,11 +277,11 @@ export class RedisAdapter implements CacheClient {
`*${pattern}*`,
'COUNT',
'1000',
RedisAdapter.responseCallback(resolve, reject),
RedisAdapter.responseScanCommandCallback(resolve, reject),
);
});
}

throw new Error('Redis client is not accepting connections.');
}
}
}

0 comments on commit 4cbd96e

Please sign in to comment.