HttpCache class

A cache for HttpClient. Request originated from this cache are stored in memory.

Constructors

HttpCache({int maxCacheMemory = 0, Duration timeout = _noDuration, bool verbose = false})

Properties

hashCode int
The hash code for this object.
no setterinherited
hasMaxCacheMemory bool
Returns true if the cache has a memory limit.
no setter
hasTimeout bool
Returns true if the cached request have timeout.
no setter
maxCacheMemory int
The maximum memory usage.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration
The timeout of stored requests.
getter/setter pair
verbose bool
If true shows cached requests in console.
getter/setter pair

Methods

calculateCacheUsedMemory() int
Returns the current cache usage of memory.
cleanCache(int maxMemory) int
cleanCacheTimedOut([Duration? timeout]) int
clearCache() int
Cleans the cached requests.
ensureCacheBelowMaxMemory([int extraMemoryNeeded = 0]) int
get(HttpClient httpClient, String? path, {bool fullPath = false, Credential? authorization, Map<String, String?>? parameters, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future<HttpResponse>
Does a GET request.
getCachedRequest(HttpClient httpClient, HttpMethod method, String path, {bool fullPath = false, Credential? authorization, Map<String, String?>? queryParameters, Object? body, String? contentType, String? accept}) HttpResponse?
Gets a request already in cache using httpClient.
getCachedRequestURL(HttpMethod method, String requestURL, {Credential? authorization, Map<String, String?>? queryParameters, Object? body, String? contentType, String? accept}) HttpResponse?
Gets a request already in cache using httpClient and requestURL.
getJSON(HttpClient httpClient, String path, {bool fullPath = false, Credential? authorization, Map<String, String?>? parameters, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future
Does a GET request and decodes response to JSON.
getURL(String url, {HttpClient? httpClient, bool fullPath = false, Credential? authorization, Map<String, String?>? parameters, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future<HttpResponse>
Does a GET request using url.
Does a HEAD request.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
options(HttpClient httpClient, String path, {bool fullPath = false, Credential? authorization, Map<String, String?>? parameters, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future<HttpResponse>
Does an OPTIONS request.
optionsJSON(HttpClient httpClient, String path, {bool fullPath = false, Credential? authorization, Map<String, String?>? parameters, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future
Does an OPTIONS request and decodes response to JSON.
post(HttpClient httpClient, String path, {bool fullPath = false, Credential? authorization, Map<String, String?>? parameters, Object? body, String? contentType, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future<HttpResponse>
Does a POST request.
postJSON(HttpClient httpClient, String path, {bool fullPath = false, Credential? authorization, Map<String, String?>? parameters, Object? body, String? contentType, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future
Does a POST request and decodes response to JSON.
put(HttpClient httpClient, String path, {bool fullPath = false, Credential? authorization, Object? body, String? contentType, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future<HttpResponse>
Does a PUT request.
putJSON(HttpClient httpClient, String path, {bool fullPath = false, Credential? authorization, Object? body, String? contentType, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future
Does a PUT request and decodes response to JSON.
request(HttpClient httpClient, HttpMethod method, String? path, {bool fullPath = false, Credential? authorization, Map<String, String?>? queryParameters, Object? body, String? contentType, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future<HttpResponse>
Does a cached request using httpClient.
requestJSON(HttpClient httpClient, HttpMethod method, String path, {bool fullPath = false, Credential? authorization, Map<String, String?>? queryParameters, Object? body, String? contentType, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future
Does a request and decodes response to JSON.
requestURL(HttpClient? httpClient, HttpMethod method, String requestURL, {Credential? authorization, Map<String, String?>? queryParameters, Object? body, String? contentType, String? accept, OnCachedResponse? onStaleResponse, Duration? staleResponseDelay}) Future<HttpResponse>
Does a cached request using httpClient and requestURL.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited