UNPKG

optivise

Version:

Optivise - The Ultimate Optimizely Development Assistant with AI-powered features, zero-config setup, and comprehensive development support

25 lines 689 B
import crypto from 'crypto'; export class PromptCache { ttlMs; store = new Map(); constructor(ttlMs = 5 * 60 * 1000) { this.ttlMs = ttlMs; } static hashPrompt(prompt) { return crypto.createHash('sha256').update(prompt).digest('hex'); } get(key) { const entry = this.store.get(key); if (!entry) return undefined; if (Date.now() - entry.timestamp > this.ttlMs) { this.store.delete(key); return undefined; } return entry.value; } set(key, value) { this.store.set(key, { key, value, timestamp: Date.now() }); } } //# sourceMappingURL=prompt-cache.js.map