Package kong.unirest.core
Class Cache.Builder
- java.lang.Object
-
- kong.unirest.core.Cache.Builder
-
- Enclosing interface:
- Cache
public static class Cache.Builder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Cache.Builder
backingCache(Cache cache)
Sets a custom backing cache.(package private) CacheManager
build()
Cache.Builder
depth(int value)
defines the max depth of the cache in number of values.Cache.Builder
maxAge(long number, java.util.concurrent.TimeUnit units)
Sets a Time-To-Live for response objects.Cache.Builder
withKeyGen(Cache.KeyGenerator keyGenerator)
Provide a custom key generator.
-
-
-
Field Detail
-
depth
private int depth
-
ttl
private long ttl
-
backing
private Cache backing
-
keyGen
private Cache.KeyGenerator keyGen
-
-
Method Detail
-
build
CacheManager build()
-
depth
public Cache.Builder depth(int value)
defines the max depth of the cache in number of values. defaults to 100. Elements exceeding the depth are purged on read. Custom Cache implementations may not honor this setting- Parameters:
value
- the max depth- Returns:
- the current builder.
-
maxAge
public Cache.Builder maxAge(long number, java.util.concurrent.TimeUnit units)
Sets a Time-To-Live for response objects. There is no TTL by default and objects will be kept indefinitely Elements exceeding the TTL are purged on read. Custom Cache implementations may not honor this setting- Parameters:
number
- a numberunits
- the TimeUnits of the number- Returns:
- this builder.
-
backingCache
public Cache.Builder backingCache(Cache cache)
Sets a custom backing cache. This cache must implement it's own purging rules There is no TTL by default and objects will be kept indefinitely- Parameters:
cache
- the backing cache implementation- Returns:
- this builder.
-
withKeyGen
public Cache.Builder withKeyGen(Cache.KeyGenerator keyGenerator)
Provide a custom key generator. The default key is a hash of the request, the request execution type and the response type.- Parameters:
keyGenerator
- a custom cache key generator- Returns:
- this builder
-
-