CacheManager<T> class
final
A generic, in-memory cache with optional time-based expiration.
Constructors
Properties
Methods
-
cache(
String key, T value, {Duration? cacheDuration}) → void -
Caches a
valuewith a givenkey. -
clear(
) → void - Removes all entries and cancels all pending expiration timers.
-
containsKey(
String? key) → bool -
Returns
trueifkeyis present and not expired. -
dispose(
) → void - Cancels timers and clears the cache. After calling this, the manager can still be reused.
-
get(
String? key) → T? - Retrieves an item from the cache.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
String? key) → T? -
Removes the entry for
key(if any) and returns its value, ornullif the key was absent or expired. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
String? key) → T? - Syntactic sugar for getting a cached item using map-like access.