import { CacheConfig } from "../shared/src/cache.js";

//#region src/cache/index.d.ts

/**
 * Cache manager class to handle cache operations.
 * Can be used with in-memory storage or persistent storage (Lakebase).
 *
 * The cache is automatically initialized by AppKit. Use `getInstanceSync()` to access
 * the singleton instance after initialization.
 *
 * @internal
 * @example
 * ```typescript
 * const cache = CacheManager.getInstanceSync();
 * const result = await cache.getOrExecute(["users", userId], () => fetchUser(userId), userKey);
 * ```
 */
declare class CacheManager {
  private static readonly MIN_CLEANUP_INTERVAL_MS;
  private readonly name;
  private static instance;
  private static initPromise;
  private storage;
  private config;
  private inFlightRequests;
  private cleanupInProgress;
  private lastCleanupAttempt;
  private telemetry;
  private telemetryMetrics;
  private constructor();
  /**
   * Get the singleton instance of the cache manager (sync version).
   *
   * Throws if not initialized - ensure AppKit.create() has completed first.
   * @returns CacheManager instance
   */
  static getInstanceSync(): CacheManager;
  /**
   * Initialize and get the singleton instance of the cache manager.
   * Called internally by AppKit - prefer `getInstanceSync()` for plugin access.
   * @param userConfig - User configuration for the cache manager
   * @returns CacheManager instance
   * @internal
   */
  static getInstance(userConfig?: Partial<CacheConfig>): Promise<CacheManager>;
  /**
   * Create a new cache manager instance
   *
   * Storage selection logic:
   * 1. If `storage` provided and healthy → use provided storage
   * 2. If `storage` provided but unhealthy → fallback to InMemory (or disable if strictPersistence)
   * 3. If no `storage` provided and Lakebase available → use Lakebase
   * 4. If no `storage` provided and Lakebase unavailable → fallback to InMemory (or disable if strictPersistence)
   *
   * @param userConfig - User configuration for the cache manager
   * @returns CacheManager instance
   */
  private static create;
  /**
   * Get or execute a function and cache the result
   * @param key - Cache key
   * @param fn - Function to execute
   * @param userKey - User key
   * @param options - Options for the cache
   * @returns Promise of the result
   */
  getOrExecute<T>(key: (string | number | object)[], fn: () => Promise<T>, userKey: string, options?: {
    ttl?: number;
  }): Promise<T>;
  /**
   * Get a cached value
   * @param key - Cache key
   * @returns Promise of the value or null if not found or expired
   */
  get<T>(key: string): Promise<T | null>;
  /** Probabilistically trigger cleanup of expired entries (fire-and-forget) */
  private maybeCleanup;
  /**
   * Set a value in the cache
   * @param key - Cache key
   * @param value - Value to set
   * @param options - Options for the cache
   * @returns Promise of the result
   */
  set<T>(key: string, value: T, options?: {
    ttl?: number;
  }): Promise<void>;
  /**
   * Delete a value from the cache
   * @param key - Cache key
   * @returns Promise of the result
   */
  delete(key: string): Promise<void>;
  /** Clear the cache */
  clear(): Promise<void>;
  /**
   * Check if a value exists in the cache
   * @param key - Cache key
   * @returns Promise of true if the value exists, false otherwise
   */
  has(key: string): Promise<boolean>;
  /**
   * Generate a cache key
   * @param parts - Parts of the key
   * @param userKey - User key
   * @returns Cache key
   */
  generateKey(parts: (string | number | object)[], userKey: string): string;
  /** Close the cache */
  close(): Promise<void>;
  /**
   * Check if the storage is healthy
   * @returns Promise of true if the storage is healthy, false otherwise
   */
  isStorageHealthy(): Promise<boolean>;
}
//#endregion
export { CacheManager };
//# sourceMappingURL=index.d.ts.map