Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
fix: add support for redis.options.keyPrefix
Browse files Browse the repository at this point in the history
  • Loading branch information
ssut committed Jun 1, 2021
1 parent 6ce0e81 commit 29b009f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/throttler-storage-redis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ export class ThrottlerStorageRedisService implements ThrottlerStorageRedis {
}

async getRecord(key: string): Promise<number[]> {
const ttls = (await this.redis.scan(0, 'MATCH', `${key}:*`, 'COUNT', this.scanCount)).pop();
const ttls = (
await this.redis.scan(
0,
'MATCH',
`${this.redis.options.keyPrefix}${key}:*`,
'COUNT',
this.scanCount,
)
).pop();
return (ttls as string[]).map((k) => parseInt(k.split(':').pop())).sort();
}

Expand Down

0 comments on commit 29b009f

Please sign in to comment.