Table of Contents

Class ModelCache<T>

Namespace
AiDotNet.Deployment.Runtime
Assembly
AiDotNet.dll

Cache for model inference results.

public class ModelCache<T>

Type Parameters

T

The numeric type for tensors

Inheritance
ModelCache<T>
Inherited Members

Constructors

ModelCache(bool)

public ModelCache(bool enabled = true)

Parameters

enabled bool

Methods

Clear()

Clears the cache.

public void Clear()

EvictLFU(int)

Evicts least frequently used entries. Note: Enumeration provides a snapshot of the cache, so concurrent modifications are safe but counts may be approximate.

public int EvictLFU(int maxEntries)

Parameters

maxEntries int

Returns

int

EvictLRU(int)

Evicts least recently used entries to maintain size limit. Note: Enumeration provides a snapshot of the cache, so concurrent modifications are safe but counts may be approximate.

public int EvictLRU(int maxEntries)

Parameters

maxEntries int

Returns

int

EvictOlderThan(TimeSpan)

Removes entries older than the specified age. Note: Enumeration provides a snapshot of the cache, so concurrent modifications are safe but counts may be approximate.

public int EvictOlderThan(TimeSpan maxAge)

Parameters

maxAge TimeSpan

Returns

int

Get(string, T[])

Gets a cached result for the given input.

public T[]? Get(string modelKey, T[] input)

Parameters

modelKey string
input T[]

Returns

T[]

GetStatistics()

Gets cache statistics.

public CacheStatistics GetStatistics()

Returns

CacheStatistics

Put(string, T[], T[])

Puts a result in the cache.

public void Put(string modelKey, T[] input, T[] result)

Parameters

modelKey string
input T[]
result T[]