CacheManager<T> class final

A generic, in-memory cache with optional time-based expiration.

Constructors

CacheManager()

Properties

hashCode int
The hash code for this object.
no setterinherited
length int
The number of entries currently in the cache, including any that are expired but have not yet been evicted.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cache(String key, T value, {Duration? cacheDuration}) → void
Caches a value with a given key.
clear() → void
Removes all entries and cancels all pending expiration timers.
containsKey(String? key) bool
Returns true if key is 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, or null if 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.