java.lang.Object
com.github.mizosoft.methanol.internal.cache.CacheInterceptor
- All Implemented Interfaces:
Methanol.Interceptor
An
Methanol.Interceptor
that serves incoming requests from cache, network, both (in case of
successful/failed revalidation), or none (in case of unsatisfiable requests). The interceptor
also updates, populates and invalidates cache entries as necessary.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.github.mizosoft.methanol.Methanol.Interceptor
Methanol.Interceptor.Chain<T>
-
Constructor Summary
ConstructorDescriptionCacheInterceptor
(LocalCache cache, HttpCache.Listener listener, Executor executor, Clock clock) -
Method Summary
Modifier and TypeMethodDescription<T> HttpResponse
<T> intercept
(HttpRequest request, Methanol.Interceptor.Chain<T> chain) Intercepts given request and returns the resulting response, usually by forwarding to the given chain.<T> CompletableFuture
<HttpResponse<T>> interceptAsync
(HttpRequest request, Methanol.Interceptor.Chain<T> chain) Intercepts the given request and returns aCompletableFuture
for the resulting response, usually by forwarding to the given chain.
-
Constructor Details
-
CacheInterceptor
public CacheInterceptor(LocalCache cache, HttpCache.Listener listener, Executor executor, Clock clock)
-
-
Method Details
-
intercept
public <T> HttpResponse<T> intercept(HttpRequest request, Methanol.Interceptor.Chain<T> chain) throws IOException, InterruptedException Description copied from interface:Methanol.Interceptor
Intercepts given request and returns the resulting response, usually by forwarding to the given chain.- Specified by:
intercept
in interfaceMethanol.Interceptor
- Throws:
IOException
InterruptedException
-
interceptAsync
public <T> CompletableFuture<HttpResponse<T>> interceptAsync(HttpRequest request, Methanol.Interceptor.Chain<T> chain) Description copied from interface:Methanol.Interceptor
Intercepts the given request and returns aCompletableFuture
for the resulting response, usually by forwarding to the given chain.- Specified by:
interceptAsync
in interfaceMethanol.Interceptor
-