LruCacheImpl<K, V> class
abstract
An abstract base class that provides a partial implementation of the LruCache interface.
This class manages the core data structures and statistics for an LRU cache, including the underlying map, size tracking, and synchronization. Subclasses should implement the remaining logic for cache operations.
- Inheritance
- Implementers
Constructors
- LruCacheImpl.new(int maxSize)
-
Constructs an LruCacheImpl with the specified
maxSize
.
Properties
- evictionCount ↔ int
-
The total number of times an entry has been evicted from the cache.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- hitCount ↔ int
-
The total number of cache hits (successful lookups).
getter/setter pair
- lock → Lock
-
A lock used to synchronize access to the cache for thread safety.
final
-
map
↔ LinkedHashMap<
K, V> -
The map that stores the cache entries in access order.
latefinal
- maxSize ↔ int
-
The maximum number of entries the cache can hold.
getter/setter pair
- missCount ↔ int
-
The total number of cache misses (failed lookups).
getter/setter pair
- putCount ↔ int
-
The total number of times an entry has been added to the cache.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size ↔ int
-
The current number of entries in the cache.
getter/setter pair
Methods
-
clear(
) → Future< void> -
Removes all entries from the cache.
override
-
get(
K key) → Future< V?> -
Returns the value associated with the given
key
, ornull
if the key is not present.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
K key, V value) → Future< V?> -
Inserts or updates the value for the given
key
in the cache.inherited -
remove(
K key) → Future< V?> -
Removes the entry for the specified
key
from the cache, if it exists.inherited -
resize(
int maxSize) → Future< void> -
Resizes the cache to the new
maxSize
.override -
toString(
) → String -
Returns a string representation of the cache, including statistics such as
maximum size, hit count, miss count, and hit rate percentage.
override
-
trimToSize(
int maxSize) → Future< void> -
Trims the cache so that its size does not exceed
maxSize
.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited