Interface IRequestCache
- Namespace
- Fusillade
- Assembly
- Fusillade.dll
This Interface is a simple cache for HTTP requests - it is intentionally not designed to conform to HTTP caching rules since you most likely want to override those rules in a client app anyways.
public interface IRequestCache
- Extension Methods
Methods
Fetch(HttpRequestMessage, string, CancellationToken)
Implement this by loading the Body of the given request / key.
Task<byte[]> Fetch(HttpRequestMessage request, string key, CancellationToken ct)
Parameters
request
HttpRequestMessageThe originating request.
key
stringA unique key used to identify the request details, that was given in Save().
ct
CancellationTokenCancellation token.
Returns
- Task<byte[]>
The Body of the given request, or null if the search completed successfully but the response was not found.
Save(HttpRequestMessage, HttpResponseMessage, string, CancellationToken)
Implement this method by saving the Body of the response. The response is already downloaded as a ByteArrayContent so you don't have to worry about consuming the stream.
Task Save(HttpRequestMessage request, HttpResponseMessage response, string key, CancellationToken ct)
Parameters
request
HttpRequestMessageThe originating request.
response
HttpResponseMessageThe response whose body you should save.
key
stringA unique key used to identify the request details.
ct
CancellationTokenCancellation token.
Returns
- Task
Completion.