/** * Embedding Cache - PostgreSQL Implementation * * Caches embeddings using SHA-256 content hash to avoid redundant API calls. * Async implementation using Prisma ORM. */ import type { EmbeddingCacheStats, EmbeddingCacheStore } from "./embedding-cache-contract.js"; export interface EmbeddingCacheEntry { provider?: string; model: string; contentHash: string; embedding: number[]; dimensions: number; createdAt: number; } export type { EmbeddingCacheStats } from "./embedding-cache-contract.js"; /** * Embedding Cache using PostgreSQL * * Pattern: * - Use SHA-256 hash of content as cache key * - Namespace the primary key by provider + model + exact content hash * - Track dimensions for validation * - Automatic cleanup of old entries */ export declare class EmbeddingCachePg implements EmbeddingCacheStore { private readonly model; private readonly namespace; private hits; private misses; constructor(provider: string, model: string); private get prisma(); /** * Hash text content using SHA-256 */ private hashContent; /** * Serialize embedding to bytes (for PostgreSQL BYTEA) */ private serializeEmbedding; /** * Deserialize embedding from bytes */ private deserializeEmbedding; /** * Get cached embedding for text */ get(text: string): Promise; /** * Store embedding in cache */ set(text: string, embedding: number[]): Promise; /** * Batch get embeddings */ getBatch(texts: string[]): Promise<(number[] | null)[]>; /** * Batch store embeddings */ setBatch(texts: string[], embeddings: number[][]): Promise; /** * Get cache statistics */ getStats(): Promise; /** * Clean up old entries */ cleanup(maxAgeMs: number): Promise; /** * Clear all cache entries for this model */ clear(): Promise; /** * Get hit rate for monitoring */ getHitRate(): number; } //# sourceMappingURL=embedding-cache-pg.d.ts.map