Skip to content

Commit

Permalink
Merge pull request #239 from Digital-Engineering/bugfix/redis
Browse files Browse the repository at this point in the history
fixed bad args
  • Loading branch information
DnOberon authored and GitHub Enterprise committed Feb 20, 2023
2 parents f20113f + fc225ef commit f5f1e6c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/services/cache/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class MemoryCacheImpl implements CacheInterface {
}
flushByPattern(pattern: string): Promise<boolean> {
// in the case of memory cache, this method is the same as flush
return this.flush()
return this.flush();
}

constructor(emitter: EventEmitter) {
Expand Down Expand Up @@ -181,25 +181,27 @@ export class RedisCacheImpl implements CacheInterface {
// wrapping this in a promise, that way it won't return before stream is complete
return new Promise((resolve) => {
stream.on('data', async (keys: string[]) => {
const deleted = await this._redis.del(keys);

// deleted returns an integer indicating how many objects were
// deleted. If this does not match the length of objects found,
// throw an error
if (deleted !== keys.length) {
Logger.error(`error deleting value(s) from redis: ${deleted}`)
resolve(false)
if (keys.length > 0) {
const deleted = await this._redis.del(keys);

// deleted returns an integer indicating how many objects were
// deleted. If this does not match the length of objects found,
// throw an error
if (deleted !== keys.length) {
Logger.error(`error deleting value(s) from redis: ${deleted}`);
resolve(false);
}
}
});

stream.on('error', (e: Error) => {
Logger.error(`error deleting value(s) from redis: ${e}`);
resolve(false)
})
resolve(false);
});

stream.on('end', () => {
this._emitter.emit('flushed');
resolve(true)
resolve(true);
});
});
}
Expand Down

0 comments on commit f5f1e6c

Please sign in to comment.