/**
 * CacheService - Comprehensive caching solution for Drizzle ORM
 *
 * Features:
 * - Multiple adapters: InMemory, Redis/Valkey, Upstash
 * - Tenant-specific caching when multi-tenancy is enabled
 * - Global cache with immediate invalidation
 * - Automatic invalidation on create/update/delete operations
 * - Integration with Drizzle's Cache class
 * - Pattern-based cache key management
 */
import type { Table } from 'drizzle-orm';
import type { CacheConfig, CacheEntry, CacheStrategy, ICacheAdapter } from '../types/index.js';
export type { CacheConfig, CacheEntry, CacheStrategy, ICacheAdapter };
export declare class InMemoryCacheAdapter implements ICacheAdapter {
    private cache;
    private maxSize;
    private cleanupInterval;
    constructor(maxSizeGB?: number);
    get(key: string): Promise<any | null>;
    set(key: string, value: any, ttl?: number, metadata?: {
        tables: string[];
        tags: string[];
        tenant?: string | null;
    }): Promise<void>;
    delete(key: string): Promise<void>;
    clear(): Promise<void>;
    invalidateByPattern(pattern: string): Promise<void>;
    invalidateByTables(tables: string[], tenant?: string | null): Promise<void>;
    invalidateByTags(tags: string[], tenant?: string | null): Promise<void>;
    getStats(): Promise<{
        keys: number;
        size: number;
    }>;
    close(): Promise<void>;
    private getCurrentSize;
    private ensureCapacity;
    private cleanupExpired;
}
export declare class RedisCacheAdapter implements ICacheAdapter {
    private client;
    private metadataPrefix;
    constructor(redisClient: any);
    get(key: string): Promise<any | null>;
    set(key: string, value: any, ttl?: number, metadata?: {
        tables: string[];
        tags: string[];
        tenant?: string | null;
    }): Promise<void>;
    delete(key: string): Promise<void>;
    clear(): Promise<void>;
    invalidateByPattern(pattern: string): Promise<void>;
    invalidateByTables(tables: string[], tenant?: string | null): Promise<void>;
    invalidateByTags(tags: string[], tenant?: string | null): Promise<void>;
    getStats(): Promise<{
        keys: number;
        size?: number;
    }>;
    close(): Promise<void>;
}
export declare class UpstashCacheAdapter implements ICacheAdapter {
    private client;
    private metadataPrefix;
    constructor(upstashClient: any);
    get(key: string): Promise<any | null>;
    set(key: string, value: any, ttl?: number, metadata?: {
        tables: string[];
        tags: string[];
        tenant?: string | null;
    }): Promise<void>;
    delete(key: string): Promise<void>;
    clear(): Promise<void>;
    invalidateByPattern(pattern: string): Promise<void>;
    invalidateByTables(tables: string[], tenant?: string | null): Promise<void>;
    invalidateByTags(tags: string[], tenant?: string | null): Promise<void>;
    getStats(): Promise<{
        keys: number;
        size?: number;
    }>;
    close(): Promise<void>;
}
/**
 * BaasixDrizzleCache - Implements Drizzle's cache interface
 * Integrates with our adapter system and provides tenant-aware caching
 */
export declare class BaasixDrizzleCache {
    private adapter;
    private defaultTTL;
    private cacheStrategy;
    private multiTenant;
    private currentTenant;
    constructor(adapter: ICacheAdapter, options?: {
        strategy?: CacheStrategy;
        defaultTTL?: number;
        multiTenant?: boolean;
    });
    /**
     * Set the current tenant context for cache operations
     */
    setTenant(tenantId: string | null): void;
    /**
     * Get the current tenant context
     */
    getTenant(): string | null;
    /**
     * Drizzle Cache interface: return the caching strategy
     */
    strategy(): CacheStrategy;
    /**
     * Generate cache key with tenant prefix if multi-tenant
     */
    private generateKey;
    /**
     * Drizzle Cache interface: get cached query result
     */
    get(key: string): Promise<any[] | undefined>;
    /**
     * Drizzle Cache interface: store query result
     */
    put(key: string, response: any, tables: string[], config?: CacheConfig): Promise<void>;
    /**
     * Drizzle Cache interface: invalidate cached queries
     */
    onMutate(params: {
        tags?: string | string[];
        tables?: string | string[] | Table<any>[];
    }): Promise<void>;
    /**
     * Invalidate entire cache or by collection
     */
    invalidateCollection(collection?: string | null, tenant?: string | null): Promise<void>;
    /**
     * Get cache statistics
     */
    getStats(): Promise<{
        keys: number;
        size?: number;
    }>;
    /**
     * Close cache adapter
     */
    close(): Promise<void>;
}
declare global {
    var __baasix_cacheInstance: BaasixDrizzleCache | null;
    var __baasix_cacheInitializing: Promise<BaasixDrizzleCache | null> | null;
}
/**
 * Initialize the cache service based on environment configuration
 */
export declare function initializeCacheService(): Promise<BaasixDrizzleCache | null>;
/**
 * Get the cache instance
 */
export declare function getCacheService(): BaasixDrizzleCache | null;
/**
 * Close the cache service
 */
export declare function closeCacheService(): Promise<void>;
/**
 * Invalidate entire cache or collection-specific cache
 * Compatible with old DBCache.invalidateEntireCache()
 */
export declare function invalidateEntireCache(collection?: string | null): Promise<void>;
/**
 * Invalidate by collection name
 */
export declare function invalidateCollection(collection: string): Promise<void>;
//# sourceMappingURL=CacheService.d.ts.map