- java.lang.Object
-
- io.github.nstdio.http.ext.Cache.InMemoryCacheBuilder
-
- All Implemented Interfaces:
Cache.CacheBuilder
- Enclosing interface:
- Cache
public static class Cache.InMemoryCacheBuilder extends java.lang.ObjectThe builder for in memory cache.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Cachebuild()BmaxItems(int maxItems)The maximum number of cache entries.BrequestFilter(java.util.function.Predicate<java.net.http.HttpRequest> filter)Adds given predicate to predicated chain.BresponseFilter(java.util.function.Predicate<java.net.http.HttpResponse.ResponseInfo> filter)Adds given predicate to predicated chain.Bsize(long size)The amount of bytes allowed to be stored.
-
-
-
Method Detail
-
build
public Cache build()
-
maxItems
public B maxItems(int maxItems)
The maximum number of cache entries. After reaching the limit the eldest entries will be evicted. Default is 8192.- Parameters:
maxItems- The maximum number of cache entries. Should be positive.- Returns:
- builder itself.
-
size
public B size(long size)
The amount of bytes allowed to be stored. Negative value means no memory restriction is made. Note that only response body bytes are counted.- Parameters:
size- The maximum size in bytes. Negative for no size restriction.- Returns:
- builder itself.
-
requestFilter
public B requestFilter(java.util.function.Predicate<java.net.http.HttpRequest> filter)
Adds given predicate to predicated chain. The calls with requests that did not pass given predicate will not be subjected to caching facility. Semantically request filter is equivalent toCache-Control: no-storeheader in request.- Parameters:
filter- The request filter.- Returns:
- builder itself.
-
responseFilter
public B responseFilter(java.util.function.Predicate<java.net.http.HttpResponse.ResponseInfo> filter)
Adds given predicate to predicated chain. The calls resulting with response that did not pass given predicate will not be subjected to caching facility. Semantically response filter is equivalent toCache-Control: no-storeheader in response.- Parameters:
filter- The request filter.- Returns:
- builder itself.
-
-