CacheStrategyHelper class
Helper class for managing HTTP caching strategies.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
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
Static Methods
-
cacheIfSuccessful(
{required String cacheKey, required HttpResponse response, required Duration ttl}) → void - Caches a response if it represents a success (2xx).
-
generateCacheKeyForRequest(
{required String url, Map< String, String> ? headers, dynamic body}) → String - Generates a cache key for a request.
-
getCachedOrFetch(
{required String url, Map< String, String> ? headers, dynamic body, required bool forceUpdate, required Duration ttl, required Future<HttpResponse> fetchFn()}) → Future<HttpResponse> - Generic helper: check cache → fetch → cache result.
-
getCachedResponse(
{required String cacheKey, required bool forceUpdate}) → Future< HttpResponse?> -
Retrieves cached response if available and valid.
Returns null on cache miss or when
forceUpdateis true. -
shouldUseCache(
Duration? ttl) → bool - Determines if caching should be used for a request.