Files
dmail-api/src/configs/cache.config.ts
T
2025-07-02 21:05:13 +03:30

17 lines
529 B
TypeScript
Executable File

import KeyvRedis from "@keyv/redis";
import { CacheModuleAsyncOptions } from "@nestjs/cache-manager";
import { ConfigService } from "@nestjs/config";
export function cacheConfig(): CacheModuleAsyncOptions {
return {
inject: [ConfigService],
isGlobal: true,
useFactory: async (configService: ConfigService) => {
return {
ttl: configService.getOrThrow<string>("CACHE_TTL"),
stores: [new KeyvRedis(configService.getOrThrow<string>("REDIS_URI"), { namespace: "dmail:" })],
};
},
};
}