Skip to content

Commit

Permalink
fix(helper): 🐛 redis now uses region for setting keys
Browse files Browse the repository at this point in the history
  • Loading branch information
djdembeck committed Oct 7, 2022
1 parent 6e3c678 commit 53cf6e8
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/helpers/database/redis/RedisHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { ErrorMessageRedisDelete, ErrorMessageRedisSet } from '#static/messages'
export default class RedisHelper {
instance: FastifyRedis | null
key: string
constructor(instance: FastifyRedis | null, key: string, id: string) {
constructor(instance: FastifyRedis | null, key: string, id: string, region: string) {
this.instance = instance
this.key = `${key}-${id}`
this.key = `${region}-${key}-${id}`
}

convertStringToDate(parsed: Book) {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/routes/AuthorDeleteHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class AuthorDeleteHelper {
constructor(asin: string, options: ParsedQuerystring, redis: FastifyRedis | null) {
this.asin = asin
this.paprHelper = new PaprAudibleAuthorHelper(this.asin, options)
this.redisHelper = new RedisHelper(redis, 'author', this.asin)
this.redisHelper = new RedisHelper(redis, 'author', this.asin, options.region)
}

async getAuthorFromPapr(): Promise<AuthorDocument | null> {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/routes/AuthorShowHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class AuthorShowHelper {
this.sharedHelper = new SharedHelper()
this.options = options
this.paprHelper = new PaprAudibleAuthorHelper(this.asin, this.options)
this.redisHelper = new RedisHelper(redis, 'book', this.asin)
this.redisHelper = new RedisHelper(redis, 'book', this.asin, options.region)
this.scrapeHelper = new ScrapeHelper(this.asin, this.options.region)
}

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/routes/BookDeleteHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class BookDeleteHelper {
constructor(asin: string, options: ParsedQuerystring, redis: FastifyRedis | null) {
this.asin = asin
this.paprHelper = new PaprAudibleBookHelper(this.asin, options)
this.redisHelper = new RedisHelper(redis, 'book', this.asin)
this.redisHelper = new RedisHelper(redis, 'book', this.asin, options.region)
}

async getBookFromPapr(): Promise<BookDocument | null> {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/routes/BookShowHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class BookShowHelper {
this.sharedHelper = new SharedHelper()
this.options = options
this.paprHelper = new PaprAudibleBookHelper(this.asin, this.options)
this.redisHelper = new RedisHelper(redis, 'book', this.asin)
this.redisHelper = new RedisHelper(redis, 'book', this.asin, options.region)
this.stitchHelper = new StitchHelper(this.asin, this.options.region)
}

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/routes/ChapterDeleteHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class ChapterDeleteHelper {
constructor(asin: string, options: ParsedQuerystring, redis: FastifyRedis | null) {
this.asin = asin
this.paprHelper = new PaprAudibleChapterHelper(this.asin, options)
this.redisHelper = new RedisHelper(redis, 'chapter', this.asin)
this.redisHelper = new RedisHelper(redis, 'chapter', this.asin, options.region)
}

async getChaptersFromPapr(): Promise<ChapterDocument | null> {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/routes/ChapterShowHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class ChapterShowHelper {
this.sharedHelper = new SharedHelper()
this.options = options
this.paprHelper = new PaprAudibleChapterHelper(this.asin, this.options)
this.redisHelper = new RedisHelper(redis, 'chapter', this.asin)
this.redisHelper = new RedisHelper(redis, 'chapter', this.asin, options.region)
this.chapterHelper = new ChapterHelper(this.asin, this.options.region)
}

Expand Down

0 comments on commit 53cf6e8

Please sign in to comment.