From 9259af97f10338c849f538a69af24531a1617c19 Mon Sep 17 00:00:00 2001 From: Ballbot Date: Wed, 17 Aug 2022 17:26:02 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20redis=20=EC=A0=91=EC=86=8D=20=EC=95=88?= =?UTF-8?q?=EB=90=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/constants/policy.constant.ts | 6 +-- src/libs/cache-db/cache-db.module.ts | 30 ++++++------- src/libs/cache-db/cache-db.service.ts | 57 ++++++++++++------------- 3 files changed, 46 insertions(+), 47 deletions(-) diff --git a/src/common/constants/policy.constant.ts b/src/common/constants/policy.constant.ts index 1c9d167..4b5d435 100644 --- a/src/common/constants/policy.constant.ts +++ b/src/common/constants/policy.constant.ts @@ -12,6 +12,6 @@ export const TEMPLATE_DIRECTORY = path.join(__dirname, '../../../', 'template'); export const LIFECYCLE_INTERVAL = 1000 * 10; // redis 는 도커 컨테이너에 내장되어 있습니다. -export const REDIS_HOST = 'localhost'; -export const REDIS_PORT = 6379; -export const REDIS_TTL = 0; +// export const REDIS_HOST = 'localhost'; +// export const REDIS_PORT = 6379; +// export const REDIS_TTL = 0; diff --git a/src/libs/cache-db/cache-db.module.ts b/src/libs/cache-db/cache-db.module.ts index 3302bed..ea8274f 100644 --- a/src/libs/cache-db/cache-db.module.ts +++ b/src/libs/cache-db/cache-db.module.ts @@ -1,25 +1,25 @@ import { CacheModule, Global, Module } from '@nestjs/common'; import * as redisStore from 'cache-manager-redis-store'; import { CacheDBService } from './cache-db.service'; -import { - REDIS_HOST, - REDIS_PORT, - REDIS_TTL, -} from '../../common/constants/policy.constant'; +// import { +// REDIS_HOST, +// REDIS_PORT, +// REDIS_TTL, +// } from '../../common/constants/policy.constant'; -export const cacheModule = CacheModule.registerAsync({ - useFactory: async () => ({ - store: redisStore, - host: REDIS_HOST, - port: `${REDIS_PORT}`, - ttl: REDIS_TTL, - auth_pass: '', - }), -}); +// export const cacheModule = CacheModule.registerAsync({ +// useFactory: async () => ({ +// store: redisStore, +// host: REDIS_HOST, +// port: `${REDIS_PORT}`, +// ttl: REDIS_TTL, +// auth_pass: '', +// }), +// }); @Global() @Module({ - imports: [cacheModule], + // imports: [cacheModule], providers: [CacheDBService], exports: [CacheDBService], }) diff --git a/src/libs/cache-db/cache-db.service.ts b/src/libs/cache-db/cache-db.service.ts index 4fe5c3c..0b890f5 100644 --- a/src/libs/cache-db/cache-db.service.ts +++ b/src/libs/cache-db/cache-db.service.ts @@ -3,34 +3,33 @@ import { Cache } from 'cache-manager'; @Injectable() export class CacheDBService { - constructor( - @Inject(CACHE_MANAGER) - private readonly cacheManager: Cache, - ) {} + constructor() // @Inject(CACHE_MANAGER) + // private readonly cacheManager: Cache, + {} - async set(key: string, value: T, ttl = -1) { - if (ttl === -1) { - return this.cacheManager.set(key, value); - } else { - return this.cacheManager.set(key, value, { - ttl, - }); - } - } - - async get(key: string) { - return this.cacheManager.get(key); - } - - async getKeys() { - return this.cacheManager.store.keys(); - } - - async del(key: string) { - return this.cacheManager.del(key); - } - - getCacheManager(): Cache { - return this.cacheManager; - } + // async set(key: string, value: T, ttl = -1) { + // if (ttl === -1) { + // return this.cacheManager.set(key, value); + // } else { + // return this.cacheManager.set(key, value, { + // ttl, + // }); + // } + // } + // + // async get(key: string) { + // return this.cacheManager.get(key); + // } + // + // async getKeys() { + // return this.cacheManager.store.keys(); + // } + // + // async del(key: string) { + // return this.cacheManager.del(key); + // } + // + // getCacheManager(): Cache { + // return this.cacheManager; + // } }