EpisodeCache<T, TInput, TOutput>

Models & Types · AiDotNet.MetaLearning.Data

Caches sampled episodes for reuse, reducing the cost of repeated episode generation. Useful when episode sampling is expensive (e.g., loading from disk or complex preprocessing). Supports LRU eviction when the cache exceeds a configured capacity.

Constructors

Constructor Summary
EpisodeCache(int capacity) Creates an episode cache with the specified capacity.

Properties

Property Summary
double HitRate { get; } Gets the cache hit rate as a value in [0, 1].
int Capacity { get; } Gets the maximum number of episodes the cache can hold.
int Count { get; } Gets the current number of cached episodes.
long HitCount { get; set; } Gets the total number of cache hits since creation.
long MissCount { get; set; } Gets the total number of cache misses since creation.

Methods

Method Summary
bool TryGet(int episodeId, IEpisode<T, TInput, TOutput> episode) Tries to retrieve a cached episode by its ID.
void Clear() Clears all cached episodes and resets hit/miss counters.
void Put(IEpisode<T, TInput, TOutput> episode) Adds an episode to the cache.
void PutAll(IEnumerable<IEpisode<T, TInput, TOutput>> episodes) Adds multiple episodes to the cache.