import { Mongoose } from 'mongoose';
import { RedisOptions } from 'ioredis';

declare const UNITS: {
    readonly milliseconds: 1;
    readonly millisecond: 1;
    readonly msecs: 1;
    readonly msec: 1;
    readonly ms: 1;
    readonly seconds: 1000;
    readonly second: 1000;
    readonly secs: 1000;
    readonly sec: 1000;
    readonly s: 1000;
    readonly minutes: number;
    readonly minute: number;
    readonly mins: number;
    readonly min: number;
    readonly m: number;
    readonly hours: number;
    readonly hour: number;
    readonly hrs: number;
    readonly hr: number;
    readonly h: number;
    readonly days: number;
    readonly day: number;
    readonly d: number;
    readonly weeks: number;
    readonly week: number;
    readonly w: number;
    readonly months: number;
    readonly month: number;
    readonly mo: number;
    readonly years: number;
    readonly year: number;
    readonly yrs: number;
    readonly yr: number;
    readonly y: number;
};
type Unit = keyof typeof UNITS;
type Duration = number | `${number}` | `${number}${Unit}` | `${number} ${Unit}`;

type CacheData = Record<string, unknown> | Record<string, unknown>[] | unknown[] | number | undefined;
type CacheOptions = {
    engine: 'memory' | 'redis';
    engineOptions?: RedisOptions;
    defaultTTL?: Duration;
    debug?: boolean;
    onError?: (error: Error) => void;
    maxEntries?: number;
    maxBytes?: number;
    sizeCalculation?: (value: CacheData) => number;
};
interface CacheEngine {
    get: (key: string) => Promise<CacheData> | CacheData;
    set: (key: string, value: CacheData, ttl?: Duration) => Promise<void> | void;
    del: (key: string) => Promise<void> | void;
    clear: () => Promise<void> | void;
    close: () => Promise<void> | void;
}

declare module 'mongoose' {
    interface Query<ResultType, DocType, THelpers, RawDocType> {
        cache: (this: Query<ResultType, DocType, THelpers, RawDocType>, ttl?: Duration, customKey?: string) => this;
        _key: string | null;
        getCacheKey: (this: Query<ResultType, DocType, THelpers, RawDocType>) => string;
        _ttl: Duration | null;
        getDuration: (this: Query<ResultType, DocType, THelpers, RawDocType>) => Duration | null;
        op?: string;
        _path?: unknown;
        _fields?: unknown;
        _distinct?: unknown;
        _conditions?: unknown;
    }
    interface Aggregate<ResultType> {
        cache: (this: Aggregate<ResultType>, ttl?: Duration, customKey?: string) => this;
        _key: string | null;
        getCacheKey: (this: Aggregate<ResultType>) => string;
        _ttl: Duration | null;
        getDuration: (this: Aggregate<ResultType>) => Duration | null;
    }
}
declare class CacheMongoose {
    #private;
    private cache;
    private constructor();
    static init(mongoose: Mongoose, cacheOptions: CacheOptions): CacheMongoose;
    clear(customKey?: string): Promise<void>;
    close(): Promise<void>;
}

export { CacheMongoose as default };
export type { CacheData, CacheEngine, CacheOptions, Duration };
//# sourceMappingURL=index.d.mts.map
