Package kong.unirest.core
Class Cache.Builder
java.lang.Object
kong.unirest.core.Cache.Builder
- Enclosing interface:
Cache
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbackingCache
(Cache cache) Sets a custom backing cache.(package private) CacheManager
build()
depth
(int value) defines the max depth of the cache in number of values.Sets a Time-To-Live for response objects.withKeyGen
(Cache.KeyGenerator keyGenerator) Provide a custom key generator.
-
Field Details
-
depth
private int depth -
ttl
private long ttl -
backing
-
keyGen
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
CacheManager build() -
depth
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
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
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
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
-