CacheManager class
Manages cached data with TTL support.
final cache = CacheManager();
cache.set('user', userData, ttl: Duration(minutes: 5));
final user = cache.get<UserModel>('user');
Constructors
- CacheManager({CacheStore? store, Duration defaultTtl = const Duration(minutes: 5), NetworkLogger? logger})
- Creates a CacheManager.
Properties
- defaultTtl → Duration
-
Default time-to-live for entries that don't specify their own.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → void - Remove all entries.
-
get<
T> (String key) → T? -
Retrieve a cached value of type
Tbykey. -
has(
String key) → bool -
Check whether a valid (non-expired) entry exists for
key. -
invalidate(
String key) → void - Remove a single cache entry.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
set<
T> (String key, T value, {Duration? ttl}) → void -
Store a
valueunderkeywith an optionalttl. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited