23 lines
617 B
TypeScript
23 lines
617 B
TypeScript
|
|
import { Global, Module } from '@nestjs/common';
|
||
|
|
import { ConfigService } from '@nestjs/config';
|
||
|
|
import Redis from 'ioredis';
|
||
|
|
|
||
|
|
import { buildRedisOptions, REDIS_PUB, RedisLifecycle } from '../config/redis.config.js';
|
||
|
|
|
||
|
|
import { CacheInvalidateService } from './cache-invalidate.service.js';
|
||
|
|
|
||
|
|
@Global()
|
||
|
|
@Module({
|
||
|
|
providers: [
|
||
|
|
{
|
||
|
|
provide: REDIS_PUB,
|
||
|
|
inject: [ConfigService],
|
||
|
|
useFactory: (config: ConfigService): Redis => new Redis(buildRedisOptions(config)),
|
||
|
|
},
|
||
|
|
RedisLifecycle,
|
||
|
|
CacheInvalidateService,
|
||
|
|
],
|
||
|
|
exports: [CacheInvalidateService],
|
||
|
|
})
|
||
|
|
export class CacheInvalidateModule {}
|