import { UserInfo } from '../types'; import { LiteLLMClient } from '../client'; /** * Clock abstraction for testing. Allows tests to fake time without real delays. */ export interface Clock { now(): number; } /** * Simple LRU cache with per-entry TTL. * - Max ~500 entries; LRU eviction when full. * - Each entry has its own expiry time. * - Tracks pending promises for single-flight deduplication. */ export declare class UserInfoCache { private static readonly MAX_ENTRIES; private cache; private pending; private clock; private ttlMs; constructor(ttlMs?: number, clock?: Clock); /** * Get a cached value, or null if not found or expired. */ get(userId: string): UserInfo | null; /** * Set a cache entry (does not expire). */ set(userId: string, value: UserInfo): void; /** * Invalidate a single user's cache entry. */ invalidate(userId: string): void; /** * Clear all cache entries and pending promises. */ clear(): void; /** * Internal: track a pending promise for single-flight deduplication. * Returns the promise, which is stored and shared across concurrent requests. */ private getPending; /** * Load a value through the cache with single-flight deduplication. * If the value is already cached and not expired, return it. * If another request is loading the same userId, wait for that promise. * Otherwise, call the loader and cache the result (unless null or error). * * Errors and null results are NOT cached. */ load(userId: string, loader: () => Promise): Promise; } /** * Wraps a LiteLLMClient to inject getUserInfo caching and automatic cache * invalidation on mutations. * * Returns a Proxy that: * - Routes getUserInfo(userId) through the cache * - Invalidates the cache (clear all) after any method matching the mutation pattern * - Delegates all other methods to the wrapped client unchanged */ export declare function withUserInfoCache(client: LiteLLMClient, options?: { ttlMs?: number; clock?: Clock; }): LiteLLMClient;