TokenInMemoryLruCacheTKey, TValue - класс

Represents an in-memory Least Recently Used (LRU) cache for tokens. This cache automatically removes the least recently used tokens when the capacity is exceeded. It also supports automatic cleanup of tokens, based on a configurable cleanup period.

Definition

Пространство имён: Tessa.Tokens.Caching
Сборка: Tessa (в Tessa.dll) Версия: 4.1.3+7e2b1422f9b8c7c41fbbc4b151a843bed05319ab
C#
public class TokenInMemoryLruCache<TKey, TValue> : ITokenCache<TKey, TValue>
Inheritance
Object    TokenInMemoryLruCacheTKey, TValue
Implements
ITokenCacheTKey, TValue

Параметры типа

TKey
TValue

Конструкторы

TokenInMemoryLruCacheTKey, TValue Represents an in-memory Least Recently Used (LRU) cache for tokens. This cache automatically removes the least recently used tokens when the capacity is exceeded. It also supports automatic cleanup of tokens, based on a configurable cleanup period.

Методы

Cleanup Performs cleanup of cache entries, if necessary.
Clear Clears the cache and resets its state, removing all entries.
EqualsDetermines whether the specified object is equal to the current object.
(Унаследован от Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Унаследован от Object)
GetHashCodeServes as the default hash function.
(Унаследован от Object)
GetTypeGets the Type of the current instance.
(Унаследован от Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Унаследован от Object)
ReleaseCleanupLock Releases a lock for cleaning up the cache.
ToStringReturns a string that represents the current object.
(Унаследован от Object)
TryAcquireCleanupLock Attempts to acquire a lock for cleaning up the cache if it hasn't already been acquired.
TryAddOrUpdate Attempts to add or update the cache value associated with the specified key.
TryGet(FuncTKey, TValue, Boolean, TValue) Attempts to retrieve the cache value that matches the specified condition.
TryGet(TKey, TValue) Attempts to retrieve the cache value associated with the specified key.
TryRemove(FuncTKey, TValue, Boolean, TValue) Attempts to remove the cache value that matches the specified condition.
TryRemove(TKey, TValue) Attempts to remove the cache value associated with the specified key.
TryUpdate Attempts to update the cache value that matches the specified condition.

Поля

CacheList A doubly linked list that stores the keys in the order of usage. The most recently used key is moved to the front, while the least recently used is at the end. This is used to efficiently remove the least recently used (LRU) token when the cache reaches its capacity.
CacheLock The object used to synchronize access to the cache. Ensures thread safety for operations that modify the cache, such as adding, removing, and cleaning up entries.
CacheMap Cached values.
Capacity The maximum number of tokens that the cache can store. When the cache exceeds this capacity, the least recently used (LRU) entry will be removed.
CleanupPredicate A predicate function used to determine whether a cache entry should be removed during cleanup, or null, if all cached entries can be cleaned up.
Clock Объект для предоставления текущего времени в формате Utc.
GetCleanupPeriodFunc Period after which tokens should be removed from the cache.
Allowed values:
  • < 0 – no automatic cleanup will occur;
  • 0 – cleaning each time the token is received;
  • > 0 – cleaning at specified intervals.
LastCleanup Date/time of last cleanup in UTC.

См. также