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
requestHttpRequestMessageThe originating request.
keystringA unique key used to identify the request details, that was given in Save().
ctCancellationTokenCancellation 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
requestHttpRequestMessageThe originating request.
responseHttpResponseMessageThe response whose body you should save.
keystringA unique key used to identify the request details.
ctCancellationTokenCancellation token.
Returns
- Task
Completion.