Skip to content

Commit

Permalink
Merge pull request #406 from boostcampwm2023/BE-setRedis-#356
Browse files Browse the repository at this point in the history
[BE/#356] 서버 Redis 연결
  • Loading branch information
koomin1227 authored Dec 9, 2023
2 parents ba21b38 + bcc5bf7 commit f8c2c55
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
110 changes: 110 additions & 0 deletions BE/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions BE/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.454.0",
"@nestjs/cache-manager": "^2.1.1",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.0.0",
Expand All @@ -31,6 +32,8 @@
"@nestjs/swagger": "^7.1.15",
"@nestjs/typeorm": "^10.0.1",
"@nestjs/websockets": "^10.2.10",
"cache-manager": "^5.3.1",
"cache-manager-ioredis": "^2.1.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"firebase-admin": "^11.11.1",
Expand All @@ -52,6 +55,7 @@
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.2.10",
"@types/cache-manager": "^4.0.6",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.2",
"@types/multer-s3": "^3.0.3",
Expand Down
5 changes: 5 additions & 0 deletions BE/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { PostsBlockModule } from './posts-block/posts-block.module';
import { UsersBlockModule } from './users-block/users-block.module';
import { LoginModule } from './login/login.module';
import { ChatModule } from './chat/chat.module';
import { CacheModule } from '@nestjs/cache-manager';
import { RedisConfigProvider } from './config/redis.config';

@Module({
imports: [
Expand All @@ -27,6 +29,9 @@ import { ChatModule } from './chat/chat.module';
TypeOrmModule.forRootAsync({
useClass: MysqlConfigProvider,
}),
CacheModule.registerAsync({
useClass: RedisConfigProvider,
}),
PostsBlockModule,
UsersBlockModule,
PostModule,
Expand Down
13 changes: 13 additions & 0 deletions BE/src/config/redis.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CacheModuleOptions, CacheOptionsFactory } from '@nestjs/common/cache';
import { ConfigService } from '@nestjs/config';
import * as redisStore from 'cache-manager-ioredis';
export class RedisConfigProvider implements CacheOptionsFactory {
configService = new ConfigService();
createCacheOptions(): CacheModuleOptions {
return {
store: redisStore,
host: this.configService.get('REDIS_HOST'),
port: this.configService.get('REDIS_PORT'),
};
}
}

0 comments on commit f8c2c55

Please sign in to comment.