Skip to content
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
159 changes: 52 additions & 107 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@
"@nestjs/throttler": "^6.4.0",
"@nestjs/websockets": "^10.4.20",
"@prisma/client": "^6.16.2",
"@types/cache-manager-redis-store": "^3.0.0",
"@keyv/redis": "^5.1.6",
"axios": "^1.20.0",
"bcrypt": "^5.1.0",
"cache-manager": "^7.2.0",
"cache-manager-redis-store": "^3.0.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"cookie-parser": "^1.4.7",
Expand Down
18 changes: 11 additions & 7 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { CacheModule } from '@nestjs/cache-manager';
import { ScheduleModule } from '@nestjs/schedule';
import { redisStore } from 'cache-manager-redis-store';
import { createKeyv } from '@keyv/redis';
import { resolveJwtExpiresIn } from './common/utils/jwt-expires.util';
import { JwtAuthGuard } from './common/guards/jwt-auth.guard';
import { AuthModule } from './modules/auth/auth.module';
Expand Down Expand Up @@ -41,16 +41,20 @@ import { IntegrationsModule } from './modules/integrations/integrations.module';
PrismaModule,

// Redis缓存配置
// cache-manager v7 は内部で Keyv を使うため、Keyv アダプタ経由で Redis に接続する。
// 旧 cache-manager-redis-store は Keyv 以前の実装で、v7 では set が成功を返しても
// 実際には Redis に書き込まれない(サイレント失敗)ため使用しない。
CacheModule.registerAsync({
isGlobal: true,
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
store: redisStore as any,
host: configService.get('REDIS_HOST', 'localhost'),
port: configService.get('REDIS_PORT', 6379),
password: configService.get('REDIS_PASSWORD', ''),
ttl: Number(configService.get('REDIS_TTL', 3600)), // 默认缓存1小时
max: 1000, // 最大缓存项数
stores: [
createKeyv({
url: `redis://${configService.get('REDIS_HOST', 'localhost')}:${configService.get('REDIS_PORT', 6379)}`,
password: configService.get('REDIS_PASSWORD') || undefined,
}),
],
ttl: Number(configService.get('REDIS_TTL', 3600)), // 默认缓存1小时(ミリ秒)
}),
inject: [ConfigService],
}),
Expand Down
Loading