import { DynamicModule } from '@nestjs/common';

/**
 * CacheModule — DynamicModule factory for the cache subsystem.
 *
 * Usage in AppModule:
 * ```typescript
 * CacheModule.forRoot({ backend: 'drizzle', defaultTtl: 300 })
 * ```
 *
 * Usage in tests:
 * ```typescript
 * CacheModule.forRoot({ backend: 'memory' })
 * ```
 *
 * `global: true` means any module that needs ICacheService can inject CACHE
 * directly without importing CacheModule. Register once in AppModule.
 *
 * The drizzle backend requires DRIZZLE to be provided globally (e.g., via DatabaseModule).
 *
 * Async configuration (`forRootAsync`):
 * The async factory returns `CacheModuleOptions`; the CACHE provider then
 * receives DRIZZLE (for the drizzle backend) through Nest DI rather than
 * hand-constructing with `null` — see issue #108 which flagged the same
 * shape in `EventsModule.forRootAsync`. DRIZZLE is injected as optional
 * so memory-backend consumers are not required to wire DatabaseModule.
 */

interface CacheModuleOptions {
    backend: 'drizzle' | 'memory';
    /** Default TTL in seconds for entries that don't specify their own TTL. Null = no expiry. */
    defaultTtl?: number;
}
interface CacheModuleAsyncOptions {
    useFactory: (...args: unknown[]) => Promise<CacheModuleOptions> | CacheModuleOptions;
    inject?: unknown[];
    imports?: unknown[];
}
declare class CacheModule {
    static forRootAsync(asyncOptions: CacheModuleAsyncOptions): DynamicModule;
    static forRoot(options?: CacheModuleOptions): DynamicModule;
}

export { CacheModule, type CacheModuleAsyncOptions, type CacheModuleOptions };
