CacheInterceptor class
An interceptor that provides simple in-memory caching for GET requests.
- Inheritance
-
- Object
- ClientInterceptor
- CacheInterceptor
Constructors
Properties
- cacheOnlySuccess → bool
-
Whether to cache only successful responses.
final
- cacheSize → int
-
Returns the number of cached entries.
no setter
- defaultMaxAge → Duration
-
Default cache duration.
final
-
excludePatterns
→ List<
RegExp> -
URL patterns to exclude from caching.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxEntries → int
-
Maximum number of entries in the cache.
final
-
methodsToCache
→ Set<
String> -
HTTP methods to cache (usually only GET).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearCache(
) → void - Clears all cached entries.
-
invalidate(
String urlPattern) → void - Invalidates cache entries matching the given URL pattern.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onError(
ClientRequest request, Object error, int attemptCount) → Future< bool> -
Called when an error occurs.
Return true to retry the request, false to propagate the error.
inherited
-
onRequest(
ClientRequest request) → Future< ClientRequest?> -
Called before the request is sent.
Return the modified request, or null to cancel the request.
override
-
onResponse(
ClientRequest request, ClientResponse response) → Future< ClientResponse> -
Called after the response is received.
Return the modified response.
override
-
removeExpired(
) → void - Removes expired entries from the cache.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited