Class CacheRevalidatorBase
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.CacheRevalidatorBase
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
DefaultAsyncCacheRevalidator
,DefaultCacheRevalidator
class CacheRevalidatorBase extends java.lang.Object implements java.io.Closeable
Abstract cache re-validation class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interface
CacheRevalidatorBase.ScheduledExecutor
-
Field Summary
Fields Modifier and Type Field Description private ConcurrentCountMap<java.lang.String>
failureCache
private static org.slf4j.Logger
LOG
private java.util.Set<java.lang.String>
pendingRequest
private CacheRevalidatorBase.ScheduledExecutor
scheduledExecutor
private SchedulingStrategy
schedulingStrategy
-
Constructor Summary
Constructors Constructor Description CacheRevalidatorBase(java.util.concurrent.ScheduledThreadPoolExecutor scheduledThreadPoolExecutor, SchedulingStrategy schedulingStrategy)
Create CacheValidator which will make ache revalidation requests using the suppliedSchedulingStrategy
andScheduledThreadPoolExecutor
.CacheRevalidatorBase(CacheRevalidatorBase.ScheduledExecutor scheduledExecutor, SchedulingStrategy schedulingStrategy)
Create CacheValidator which will make ache revalidation requests using the suppliedSchedulingStrategy
andCacheRevalidatorBase.ScheduledExecutor
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
awaitTermination(org.apache.hc.core5.util.Timeout timeout)
void
close()
(package private) java.util.Set<java.lang.String>
getScheduledIdentifiers()
(package private) boolean
isStale(org.apache.hc.core5.http.HttpResponse httpResponse)
Determines if the given response is generated from a stale cache entry.(package private) void
jobFailed(java.lang.String identifier)
(package private) void
jobSuccessful(java.lang.String identifier)
(package private) void
scheduleRevalidation(java.lang.String cacheKey, java.lang.Runnable command)
Schedules an asynchronous re-validationstatic CacheRevalidatorBase.ScheduledExecutor
wrap(java.util.concurrent.ScheduledExecutorService executorService)
-
-
-
Field Detail
-
scheduledExecutor
private final CacheRevalidatorBase.ScheduledExecutor scheduledExecutor
-
schedulingStrategy
private final SchedulingStrategy schedulingStrategy
-
pendingRequest
private final java.util.Set<java.lang.String> pendingRequest
-
failureCache
private final ConcurrentCountMap<java.lang.String> failureCache
-
LOG
private static final org.slf4j.Logger LOG
-
-
Constructor Detail
-
CacheRevalidatorBase
public CacheRevalidatorBase(CacheRevalidatorBase.ScheduledExecutor scheduledExecutor, SchedulingStrategy schedulingStrategy)
Create CacheValidator which will make ache revalidation requests using the suppliedSchedulingStrategy
andCacheRevalidatorBase.ScheduledExecutor
.
-
CacheRevalidatorBase
public CacheRevalidatorBase(java.util.concurrent.ScheduledThreadPoolExecutor scheduledThreadPoolExecutor, SchedulingStrategy schedulingStrategy)
Create CacheValidator which will make ache revalidation requests using the suppliedSchedulingStrategy
andScheduledThreadPoolExecutor
.
-
-
Method Detail
-
wrap
public static CacheRevalidatorBase.ScheduledExecutor wrap(java.util.concurrent.ScheduledExecutorService executorService)
-
scheduleRevalidation
void scheduleRevalidation(java.lang.String cacheKey, java.lang.Runnable command)
Schedules an asynchronous re-validation
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
awaitTermination
public void awaitTermination(org.apache.hc.core5.util.Timeout timeout) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
jobSuccessful
void jobSuccessful(java.lang.String identifier)
-
jobFailed
void jobFailed(java.lang.String identifier)
-
getScheduledIdentifiers
java.util.Set<java.lang.String> getScheduledIdentifiers()
-
isStale
boolean isStale(org.apache.hc.core5.http.HttpResponse httpResponse)
Determines if the given response is generated from a stale cache entry.- Parameters:
httpResponse
- the response to be checked- Returns:
- whether the response is stale or not
-
-