/**
 * Hybrid L1/L2 Cache Implementation
 *
 * Architecture:
 * - L1 (Memory): Fast reads, always local
 * - L2 (Redis): Source of truth for multi-instance sync
 *
 * For hybrid keys (permissions, settings, auth):
 * - Reads: Always from L1 (memory) - fast, no network latency
 * - Writes: Write to both L1 and L2 (Redis)
 * - Sync: Periodic sync from L2 to L1 every X seconds
 *
 * For non-hybrid keys:
 * - If Redis available: Use Redis directly
 * - If no Redis: Use in-memory only
 */
import Redis from "ioredis";
/**
 * Cache interface for both memory and Redis implementations
 */
export interface CacheInterface {
    get(key: string): Promise<any | null>;
    set(key: string, value: any, expiresIn?: number): Promise<void>;
    setBatch(entries: Array<{
        key: string;
        value: any;
        expiresIn?: number;
    }>): Promise<void>;
    delete(key: string): Promise<void>;
    del(key: string): Promise<void>;
    clear(): Promise<void>;
    invalidateModel(modelName: string): Promise<void>;
    tryLock(key: string, ttlSeconds?: number): Promise<boolean>;
    unlock(key: string): Promise<void>;
    setIfNotExists(key: string, value: any, expiresIn?: number): Promise<boolean>;
    forceSync(): Promise<void>;
    isRedisEnabled(): boolean;
}
declare global {
    var __baasix_cache: CacheInterface | null;
    var __baasix_redisClient: Redis | null;
    var __baasix_syncInterval: NodeJS.Timeout | null;
    var __baasix_isRedisEnabled: boolean;
    var __baasix_l1Cache: Map<string, {
        value: string;
        expiry: number;
    }>;
    var __baasix_lastSyncedVersion: string | null;
}
/**
 * Initialize cache with hybrid L1/L2 support
 */
export declare function initializeCache(options: {
    ttl: number;
    uri?: string | null;
}): void;
/**
 * Check if cache has been initialized
 */
export declare function isCacheInitialized(): boolean;
/**
 * Get cache instance (singleton)
 */
export declare function getCache(): CacheInterface;
/**
 * Close cache connections
 */
export declare function closeCache(): Promise<void>;
//# sourceMappingURL=cache.d.ts.map