ThanosCache<K, V> class
Implementation of MemoryCache with "Thanos-style" memory reduction.
Core feature: The reduceMemory method removes exactly half of the cache entries (inspired by Thanos snapping his fingers to kill half the universe), making it a deterministic eviction policy for memory optimization.
Type Parameters:
K: Type of cache keys (must be hashable)V: Type of cache values (can be nullable)
Note: Uses a standard Map as the underlying storage, with O(1) get/put operations.
- Implemented types
-
- MemoryCache<
K, V>
- MemoryCache<
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
get(
K key) → V? -
Retrieves a value from the cache by key.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
K key, V? value) → void -
Stores a value in the cache (or removes it if value is null).
override
-
reduceMemory(
) → int -
Reduces cache memory usage by evicting entries (implementation-specific logic).
override
-
size(
) → int -
Returns the current number of entries in the cache.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited