Class CacheInterceptor
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 Methanol.Interceptor
Methanol.Interceptor.Chain<T> -
Constructor Summary
ConstructorsConstructorDescriptionCacheInterceptor(LocalCache.Factory cacheFactory, HttpCache.Listener listener, Executor handlerExecutor, Clock clock, boolean synchronizeWrites, Predicate<String> implicitHeaderPredicate) -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanReplaceStoredHeader(String name) <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 aCompletableFuturefor the resulting response, usually by forwarding to the given chain.
-
Constructor Details
-
CacheInterceptor
public CacheInterceptor(LocalCache.Factory cacheFactory, HttpCache.Listener listener, Executor handlerExecutor, Clock clock, boolean synchronizeWrites, Predicate<String> implicitHeaderPredicate)
-
-
Method Details
-
intercept
public <T> HttpResponse<T> intercept(HttpRequest request, Methanol.Interceptor.Chain<T> chain) throws IOException, InterruptedException Description copied from interface:Methanol.InterceptorIntercepts given request and returns the resulting response, usually by forwarding to the given chain.- Specified by:
interceptin interfaceMethanol.Interceptor- Throws:
IOExceptionInterruptedException
-
interceptAsync
public <T> CompletableFuture<HttpResponse<T>> interceptAsync(HttpRequest request, Methanol.Interceptor.Chain<T> chain) Description copied from interface:Methanol.InterceptorIntercepts the given request and returns aCompletableFuturefor the resulting response, usually by forwarding to the given chain.- Specified by:
interceptAsyncin interfaceMethanol.Interceptor
-
canReplaceStoredHeader
-