Class Cache.Builder

java.lang.Object
kong.unirest.core.Cache.Builder
Enclosing interface:
Cache

public static class Cache.Builder extends Object
  • Field Details

    • depth

      private int depth
    • ttl

      private long ttl
    • backing

      private Cache backing
    • keyGen

      private Cache.KeyGenerator keyGen
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • 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, 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 number
      units - 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