Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE/#356] 서버 Redis 연결 #406

Merged
merged 3 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}),
Comment on lines +32 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

캐시 모듈 잘 쓰신 것 같네요

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'),
};
}
}
Comment on lines +4 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configService에 쓰인 환경변수 사용하는 것이 좋네요

Loading