Class HttpProfileCache.CacheBucket
java.lang.Object
com.thecsdev.common.resource.http.HttpProfileCache.CacheBucket
- Enclosing class:
HttpProfileCache
-
Method Summary
Modifier and TypeMethodDescriptionfinal booleanfinal CompletableFuture<@Nullable ResourceResponse> fetchAsync(@NotNull ResourceRequest request) Fetches the cachedResourceResponsefor the givenResourceRequest, if it exists and is valid.final @NotNull PathReturns thePathto the directory where cache data for thisHttpProfileCache.CacheBucketis stored.final inthashCode()static final @NotNull HttpProfileCache.CacheBucketof(@NotNull HttpProfileCache cache, @NotNull ResourceRequest request) Creates a newHttpProfileCache.CacheBucketinstance for the givenResourceRequest, using the givenHttpProfileCacheto determine the base directory.static final @NotNull HttpProfileCache.CacheBucketof(@NotNull HttpProfileCache cache, @NotNull String httpMethod, @NotNull URI uri) Creates a newHttpProfileCache.CacheBucketinstance for the givenURIand HTTP method, using the givenHttpProfileCacheto determine the base directory.final CompletableFuture<@Nullable Void> storeAsync(@NotNull ResourceRequest request, @NotNull ResourceResponse response) Stores the givenResourceResponsein the cache for thisHttpProfileCache.CacheBucket.
-
Method Details
-
hashCode
-
equals
-
getDirname
Returns thePathto the directory where cache data for thisHttpProfileCache.CacheBucketis stored. -
fetchAsync
public final CompletableFuture<@Nullable ResourceResponse> fetchAsync(@NotNull @NotNull ResourceRequest request) throws NullPointerException Fetches the cachedResourceResponsefor the givenResourceRequest, if it exists and is valid. Returns aCompletableFuturethat completes with the cached response, ornullthe cache is a "miss".- Parameters:
request- TheResourceRequestfor which to fetch the cached response.- Throws:
NullPointerException- If the argument isnull.
-
storeAsync
public final CompletableFuture<@Nullable Void> storeAsync(@NotNull @NotNull ResourceRequest request, @NotNull @NotNull ResourceResponse response) throws NullPointerException Stores the givenResourceResponsein the cache for thisHttpProfileCache.CacheBucket. Returns aCompletableFuturethat completes when the response has been stored.- Parameters:
response- TheResourceResponseto store in the cache.- Throws:
NullPointerException- If the argument isnull.
-
of
@NotNull public static final @NotNull HttpProfileCache.CacheBucket of(@NotNull @NotNull HttpProfileCache cache, @NotNull @NotNull ResourceRequest request) throws NullPointerException Creates a newHttpProfileCache.CacheBucketinstance for the givenResourceRequest, using the givenHttpProfileCacheto determine the base directory.- Parameters:
cache- TheHttpProfileCacheto use as the base directory for this cache entry.request- TheResourceRequestfor which to create the cache entry.- Throws:
NullPointerException- If an argument isnull.
-
of
@NotNull public static final @NotNull HttpProfileCache.CacheBucket of(@NotNull @NotNull HttpProfileCache cache, @NotNull @NotNull String httpMethod, @NotNull @NotNull URI uri) throws NullPointerException Creates a newHttpProfileCache.CacheBucketinstance for the givenURIand HTTP method, using the givenHttpProfileCacheto determine the base directory.- Parameters:
cache- TheHttpProfileCacheto use as the base directory for this cache entry.httpMethod- The HTTP method (e.g., "GET", "HEAD") associated with this cache entry.uri- TheURIassociated with this cache entry.- Throws:
NullPointerException- If an argument isnull.
-