LiveMap API
Loading...
Searching...
No Matches
livemap.util.LRUCache< TKey, TValue > Class Template Reference

Thread-safe LRU (Least Recently Used) cache implementation. Provides O(1) get and put operations with automatic eviction when capacity is exceeded. More...

Public Member Functions

 LRUCache (int capacity)
bool TryGet (TKey key, out TValue? value)
 Gets the value associated with the specified key.
void Add (TKey key, TValue value)
 Adds or updates a value in the cache.
bool Remove (TKey key)
 Removes the value with the specified key from the cache.
void Clear ()
 Removes all items from the cache.
 CacheItem (TKey key, TValue value)

Properties

int Count [get]
 Gets the number of items currently in the cache.
TKey Key [get]
TValue Value [get, set]

Detailed Description

Thread-safe LRU (Least Recently Used) cache implementation. Provides O(1) get and put operations with automatic eviction when capacity is exceeded.

Type Constraints
TKey :notnull 

Member Function Documentation

◆ Add()

void livemap.util.LRUCache< TKey, TValue >.Add ( TKey key,
TValue value )
inline

Adds or updates a value in the cache.

Parameters
keyThe key of the value to add or update.
valueThe value to add or update.

◆ CacheItem()

livemap.util.LRUCache< TKey, TValue >.CacheItem ( TKey key,
TValue value )
inline

◆ Clear()

void livemap.util.LRUCache< TKey, TValue >.Clear ( )
inline

Removes all items from the cache.

◆ LRUCache()

livemap.util.LRUCache< TKey, TValue >.LRUCache ( int capacity)
inline

◆ Remove()

bool livemap.util.LRUCache< TKey, TValue >.Remove ( TKey key)
inline

Removes the value with the specified key from the cache.

Parameters
keyThe key of the value to remove.
Returns
true if the element was successfully removed; otherwise, false.

◆ TryGet()

bool livemap.util.LRUCache< TKey, TValue >.TryGet ( TKey key,
out TValue? value )
inline

Gets the value associated with the specified key.

Parameters
keyThe key of the value to get.
valueWhen this method returns, contains the value associated with the specified key, if found; otherwise, the default value.
Returns
true if the cache contains an element with the specified key; otherwise, false.

Property Documentation

◆ Count

int livemap.util.LRUCache< TKey, TValue >.Count
get

Gets the number of items currently in the cache.

◆ Key

TKey livemap.util.LRUCache< TKey, TValue >.Key
get

◆ Value

TValue livemap.util.LRUCache< TKey, TValue >.Value
getset

The documentation for this class was generated from the following file: