Cache<K, V> constructor
Cache<K, V> ({
- required CacheStorage<
K, CacheEntry< storage,K, V> > - required EvictionAlgorithm algorithm,
- required int maxSize,
- required Future<
V> loader(- K key
Creates a new cache instance.
storage
- The storage implementation to use for caching
algorithm
- The eviction algorithm to use (LFU or LRU)
maxSize
- Maximum number of items to store in the cache
loader
- Callback function to load values from backing store
Implementation
Cache({
required CacheStorage<K, CacheEntry<K, V>> storage,
required EvictionAlgorithm algorithm,
required int maxSize,
required Future<V> Function(K key) loader,
}) : _storage = storage,
_algorithm = algorithm,
_maxSize = maxSize,
_loader = loader;