- java.lang.Object
-
- com.github.mizosoft.methanol.internal.cache.CacheInterceptor
-
- All Implemented Interfaces:
Methanol.Interceptor
public final class CacheInterceptor extends java.lang.Object implements Methanol.Interceptor
AnMethanol.Interceptorthat 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
Constructors Constructor Description CacheInterceptor(LocalCache.Factory cacheFactory, HttpCache.Listener listener, java.util.concurrent.Executor handlerExecutor, java.time.Clock clock, boolean synchronizeWrites, java.util.function.Predicate<java.lang.String> implicitHeaderPredicate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancanReplaceStoredHeader(java.lang.String name)<T> java.net.http.HttpResponse<T>intercept(java.net.http.HttpRequest request, Methanol.Interceptor.Chain<T> chain)Intercepts given request and returns the resulting response, usually by forwarding to the given chain.<T> java.util.concurrent.CompletableFuture<java.net.http.HttpResponse<T>>interceptAsync(java.net.http.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 Detail
-
CacheInterceptor
public CacheInterceptor(LocalCache.Factory cacheFactory, HttpCache.Listener listener, java.util.concurrent.Executor handlerExecutor, java.time.Clock clock, boolean synchronizeWrites, java.util.function.Predicate<java.lang.String> implicitHeaderPredicate)
-
-
Method Detail
-
intercept
public <T> java.net.http.HttpResponse<T> intercept(java.net.http.HttpRequest request, Methanol.Interceptor.Chain<T> chain) throws java.io.IOException, java.lang.InterruptedExceptionDescription 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:
java.io.IOExceptionjava.lang.InterruptedException
-
interceptAsync
public <T> java.util.concurrent.CompletableFuture<java.net.http.HttpResponse<T>> interceptAsync(java.net.http.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
public static boolean canReplaceStoredHeader(java.lang.String name)
-
-