You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
752 B
25 lines
752 B
import { CacheModule, Module } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import * as redisStore from 'cache-manager-redis-store';
|
|
|
|
import { RedisCacheService } from './redis-cache.service';
|
|
|
|
@Module({
|
|
imports: [
|
|
CacheModule.registerAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: async (configService: ConfigService) => ({
|
|
host: configService.get('REDIS_HOST'),
|
|
max: configService.get('MAX_ITEM_IN_CACHE'),
|
|
port: configService.get('REDIS_PORT'),
|
|
store: redisStore,
|
|
ttl: configService.get('CACHE_TTL')
|
|
})
|
|
})
|
|
],
|
|
providers: [RedisCacheService],
|
|
exports: [RedisCacheService]
|
|
})
|
|
export class RedisCacheModule {}
|