Class ModelCache<T>
- Namespace
- AiDotNet.Deployment.Runtime
- Assembly
- AiDotNet.dll
Cache for model inference results.
public class ModelCache<T>
Type Parameters
TThe numeric type for tensors
- Inheritance
-
ModelCache<T>
- Inherited Members
Constructors
ModelCache(bool)
public ModelCache(bool enabled = true)
Parameters
enabledbool
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
maxEntriesint
Returns
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
maxEntriesint
Returns
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
maxAgeTimeSpan
Returns
Get(string, T[])
Gets a cached result for the given input.
public T[]? Get(string modelKey, T[] input)
Parameters
modelKeystringinputT[]
Returns
- T[]
GetStatistics()
Gets cache statistics.
public CacheStatistics GetStatistics()
Returns
Put(string, T[], T[])
Puts a result in the cache.
public void Put(string modelKey, T[] input, T[] result)
Parameters
modelKeystringinputT[]resultT[]