TtlCachePolicy class
Time-to-live (TTL) cache policy.
Caches expire after a specified duration.
Example
final policy = TtlCachePolicy(
ttl: const Duration(hours: 6),
getTimestamps: () async => prefs.getInt('cache_timestamp'),
setTimestamp: (key, ts) async => prefs.setInt(key, ts),
removeTimestamp: (key) async => prefs.remove(key),
clearAll: () async => prefs.clear(),
);
- Implemented types
Constructors
Properties
Methods
-
clear(
) → Future< void> -
Clear all cached data.
override
-
invalidate(
String key) → Future< void> -
Invalidate cached data for
key.override -
isValid(
String key) → Future< bool> -
Check if cached data for
keyis still valid.override -
markFresh(
String key) → Future< void> -
Mark cached data for
keyas fresh.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited