diff --git a/package-lock.json b/package-lock.json index adb8fd8..3512f8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "@nestjs/terminus": "^9.2.2", "@prisma/client": "^4.12.0", "cache-manager": "^5.2.0", + "cache-manager-ioredis-yet": "^1.1.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "ioredis": "^5.3.1", @@ -3413,6 +3414,18 @@ "lru-cache": "~7.18.3" } }, + "node_modules/cache-manager-ioredis-yet": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/cache-manager-ioredis-yet/-/cache-manager-ioredis-yet-1.1.0.tgz", + "integrity": "sha512-bGBAq8oNzzNkO2dwlYGWBxNXrz4w8FUTpe3nfUydJ6bm1ixKEcSUKYksGokQMaRgqkQjMbIHWFkvb8p+V9ZKqw==", + "dependencies": { + "cache-manager": "^5.1.0", + "ioredis": "^5.2.3" + }, + "engines": { + "node": ">= 16.17.0" + } + }, "node_modules/cache-manager/node_modules/lru-cache": { "version": "7.18.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", diff --git a/package.json b/package.json index ce6ad16..5919315 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "@nestjs/terminus": "^9.2.2", "@prisma/client": "^4.12.0", "cache-manager": "^5.2.0", + "cache-manager-ioredis-yet": "^1.1.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "ioredis": "^5.3.1", diff --git a/src/modules/matcher/matcher.module.ts b/src/modules/matcher/matcher.module.ts index 8071f27..ef74b38 100644 --- a/src/modules/matcher/matcher.module.ts +++ b/src/modules/matcher/matcher.module.ts @@ -8,6 +8,9 @@ import { MatchProfile } from './mappers/match.profile'; import { AdRepository } from './adapters/secondaries/ad.repository'; import { MatchUseCase } from './domain/usecases/match.usecase'; import { Messager } from './adapters/secondaries/messager'; +import { CacheModule } from '@nestjs/cache-manager'; +import { RedisClientOptions } from '@liaoliaots/nestjs-redis'; +import { redisStore } from 'cache-manager-ioredis-yet'; @Module({ imports: [ @@ -27,6 +30,18 @@ import { Messager } from './adapters/secondaries/messager'; }), inject: [ConfigService], }), + CacheModule.registerAsync({ + imports: [ConfigModule], + useFactory: async (configService: ConfigService) => ({ + store: await redisStore({ + host: configService.get('REDIS_HOST'), + port: configService.get('REDIS_PORT'), + password: configService.get('REDIS_PASSWORD'), + ttl: configService.get('CACHE_TTL'), + }), + }), + inject: [ConfigService], + }), ], controllers: [MatcherController], providers: [MatchProfile, AdRepository, Messager, MatchUseCase],