Skip to content

ModelCache

Defined in: model-cache.ts:55

In-memory cache for model lists with TTL-based expiration.

Usage:

const cache = new ModelCache();
// Set with 1 hour TTL
cache.set('openai-backend', modelResult, 3600000);
// Get (returns null if expired or not found)
const cached = cache.get('openai-backend');
// Invalidate specific backend
cache.invalidate('openai-backend');
// Clear all
cache.clear();

new ModelCache(): ModelCache

Defined in: model-cache.ts:58

ModelCache

clear(): void

Defined in: model-cache.ts:123

Clear all cached model lists.

void


get(backendName): ListModelsResult | null

Defined in: model-cache.ts:68

Get cached model list for a backend.

string

Unique backend identifier

ListModelsResult | null

Cached result or null if not found/expired


has(backendName): boolean

Defined in: model-cache.ts:107

Check if backend has cached models.

string

Unique backend identifier

boolean

true if cache exists and not expired


invalidate(backendName): void

Defined in: model-cache.ts:116

Invalidate (remove) cached models for a backend.

string

Unique backend identifier

void


keys(): string[]

Defined in: model-cache.ts:150

Get all cached backend names (excluding expired).

string[]


set(backendName, result, ttl): void

Defined in: model-cache.ts:92

Cache a model list result.

string

Unique backend identifier

ListModelsResult

Model list result to cache

number

Time to live in milliseconds

void


size(): number

Defined in: model-cache.ts:130

Get number of cached backends.

number