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 TTLcache.set('openai-backend', modelResult, 3600000);
// Get (returns null if expired or not found)const cached = cache.get('openai-backend');
// Invalidate specific backendcache.invalidate('openai-backend');
// Clear allcache.clear();Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ModelCache():
ModelCache
Defined in: model-cache.ts:58
Returns
Section titled “Returns”ModelCache
Methods
Section titled “Methods”clear()
Section titled “clear()”clear():
void
Defined in: model-cache.ts:123
Clear all cached model lists.
Returns
Section titled “Returns”void
get(
backendName):ListModelsResult|null
Defined in: model-cache.ts:68
Get cached model list for a backend.
Parameters
Section titled “Parameters”backendName
Section titled “backendName”string
Unique backend identifier
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”backendName
Section titled “backendName”string
Unique backend identifier
Returns
Section titled “Returns”boolean
true if cache exists and not expired
invalidate()
Section titled “invalidate()”invalidate(
backendName):void
Defined in: model-cache.ts:116
Invalidate (remove) cached models for a backend.
Parameters
Section titled “Parameters”backendName
Section titled “backendName”string
Unique backend identifier
Returns
Section titled “Returns”void
keys()
Section titled “keys()”keys():
string[]
Defined in: model-cache.ts:150
Get all cached backend names (excluding expired).
Returns
Section titled “Returns”string[]
set(
backendName,result,ttl):void
Defined in: model-cache.ts:92
Cache a model list result.
Parameters
Section titled “Parameters”backendName
Section titled “backendName”string
Unique backend identifier
result
Section titled “result”Model list result to cache
number
Time to live in milliseconds
Returns
Section titled “Returns”void
size()
Section titled “size()”size():
number
Defined in: model-cache.ts:130
Get number of cached backends.
Returns
Section titled “Returns”number