MapAsCacheExtension<K, V> extension

Extension that ads cached methods to a Map.

on

Methods

checkCachedEntry(K key) → void

Available on Map<K, V>, provided by the MapAsCacheExtension extension

checkCacheLimit(int? cacheLimit) int

Available on Map<K, V>, provided by the MapAsCacheExtension extension

Checks if this Map.length is bigger than cacheLimit and removes elements to not exceed the cacheLimit.
getCached(K key, V computer(), {int? cacheLimit}) → V

Available on Map<K, V>, provided by the MapAsCacheExtension extension

Returns key value or computes it and caches it. See checkCachedEntry, checkCacheLimit and getCachedAsync.
getCachedAsync(K key, FutureOr<V> computer(), {int? cacheLimit}) FutureOr<V>

Available on Map<K, V>, provided by the MapAsCacheExtension extension

Same as getCached but accepts a computer that returns a Future. See checkCachedEntry, checkCacheLimit and getCachedAsync.
getCachedAsyncNullable(K key, FutureOr<V?> computer(), {int? cacheLimit}) FutureOr<V?>

Available on Map<K, V>, provided by the MapAsCacheExtension extension

getCachedNullable(K key, V? computer(), {int? cacheLimit}) → V?

Available on Map<K, V>, provided by the MapAsCacheExtension extension

getIfCached(K key, {int? cacheLimit}) → V?

Available on Map<K, V>, provided by the MapAsCacheExtension extension

Returns key value, checking if it's still valid. See checkCachedEntry and checkCacheLimit.