import { DynamicModule, OnModuleInit } from '@nestjs/common'; import type { Redis } from 'ioredis'; import { CacheService } from './cache.service'; /** * Injection token for CacheService */ export declare const CACHE_SERVICE: unique symbol; /** * Cache module configuration options */ export interface CacheModuleOptions { /** * Whether to make the module global * @default true */ isGlobal?: boolean; /** * Redis client instance (optional) * If not provided, Redis caching will be disabled */ redisClient?: Redis; /** * Default TTL for LRU cache in milliseconds */ memoryTtl?: number; /** * Namespace for LRU cache */ memoryNamespace?: string; /** * Max size for LRU cache * @default 500 */ lruMaxSize?: number; /** * Enable compression for cache values * @default false */ enableCompression?: boolean; /** * Compression threshold in bytes * @default 1024 */ compressionThreshold?: number; } /** * Unified cache module with three-tier architecture * * Provides CacheService and cache decorators (@Cacheable, @CacheEvict, @CachePut) * * @example * ```typescript * // Basic usage (without Redis) * @Module({ * imports: [ * CacheModule.forRoot() * ] * }) * export class AppModule {} * * // With Redis * import { RedisModule } from '@songkeys/nestjs-redis'; * * @Module({ * imports: [ * RedisModule.forRoot({ ... }), * CacheModule.forRootAsync({ * imports: [RedisModule], * inject: [RedisService], * useFactory: (redisService: RedisService) => ({ * redisClient: redisService.getClient() * }) * }) * ] * }) * export class AppModule {} * * // With TypeORM DataSource for DbDependency * @Module({ * imports: [ * TypeOrmModule.forRoot({ ... }), * CacheModule.forRootAsync({ * imports: [TypeOrmModule], * inject: [DataSource], * useFactory: (dataSource: DataSource) => ({ * dataSource * }) * }) * ] * }) * export class AppModule {} * ``` */ export declare class CacheModule implements OnModuleInit { private readonly cacheService; constructor(cacheService: CacheService); /** * Register cache module with options */ static forRoot(options?: CacheModuleOptions): DynamicModule; /** * Register cache module asynchronously */ static forRootAsync(options: { imports?: any[]; inject?: any[]; useFactory: (...args: any[]) => Promise | CacheModuleOptions; isGlobal?: boolean; }): DynamicModule; onModuleInit(): void; }