Fix redis setup
This commit is contained in:
@@ -16,9 +16,9 @@ import { PrometheusModule } from '@willsoto/nestjs-prometheus';
|
||||
import { MinioModule } from './minio/minio.module';
|
||||
import { KvModule } from './kv/kv.module';
|
||||
import { BullModule } from '@nestjs/bull';
|
||||
import type { RedisClientOptions } from 'redis';
|
||||
import { redisStore } from 'cache-manager-redis-store';
|
||||
import { ScheduleModule } from '@nestjs/schedule';
|
||||
import { RedisClientOptions } from 'redis';
|
||||
import { redisStore } from 'cache-manager-redis-yet';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -27,31 +27,34 @@ import { ScheduleModule } from '@nestjs/schedule';
|
||||
isGlobal: true,
|
||||
load: [configuration],
|
||||
}),
|
||||
// CacheModule.registerAsync<RedisClientOptions>({
|
||||
// isGlobal: true,
|
||||
// imports: [ConfigModule],
|
||||
// inject: [ConfigService],
|
||||
// useFactory: async (configService: ConfigService) => ({
|
||||
// store: redisStore as unknown as CacheStoreFactory,
|
||||
// ttl: configService.get<number>('CACHE_TTL', 5),
|
||||
// // Store-specific configuration:
|
||||
// password: configService.get<string>('redis.pass', ''),
|
||||
// host: configService.get<string>('redis.host', 'localhost'),
|
||||
// port: configService.get<number>('redis.port', 6379),
|
||||
// db: configService.get<number>('redis.db', 1),
|
||||
// }),
|
||||
// }),
|
||||
CacheModule.registerAsync<RedisClientOptions>({
|
||||
isGlobal: true,
|
||||
inject: [ConfigService],
|
||||
imports: [ConfigModule],
|
||||
useFactory: async (configService: ConfigService) => ({
|
||||
store: redisStore,
|
||||
socket: {
|
||||
host: configService.get<string>('redis.host'),
|
||||
port: configService.get<number>('redis.port'),
|
||||
},
|
||||
database: configService.get<number>('redis.db'),
|
||||
password: configService.get<string>('redis.password'),
|
||||
}),
|
||||
}),
|
||||
BullModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: async (configService: ConfigService) => ({
|
||||
redis: {
|
||||
password: configService.get<string>('redis.pass', ''),
|
||||
host: configService.get<string>('redis.host', 'localhost'),
|
||||
port: configService.get<number>('redis.port', 6379),
|
||||
db: configService.get<number>('redis.db', 1),
|
||||
},
|
||||
}),
|
||||
useFactory: async (configService: ConfigService) => {
|
||||
const config = {
|
||||
redis: {
|
||||
password: configService.get<string>('redis.password'),
|
||||
host: configService.get<string>('redis.host'),
|
||||
port: configService.get<number>('redis.port'),
|
||||
db: configService.get<number>('redis.db'),
|
||||
},
|
||||
};
|
||||
return config;
|
||||
},
|
||||
}),
|
||||
PrometheusModule.register({
|
||||
defaultLabels: {
|
||||
|
Reference in New Issue
Block a user