Class Cache3.Builder<K1,K2,K3,V>

java.lang.Object
org.apache.juneau.commons.collections.Cache3.Builder<K1,K2,K3,V>
Type Parameters:
K1 - The first key type.
K2 - The second key type.
K3 - The third key type.
V - The value type.
Enclosing class:
Cache3<K1,K2,K3,V>

public static class Cache3.Builder<K1,K2,K3,V> extends Object
Builder for creating configured Cache3 instances.
  • Method Details

    • build

      public Cache3<K1,K2,K3,V> build()
      Builds a new Cache3 instance with the configured settings.
      Returns:
      A new immutable Cache3 instance.
    • cacheMode

      Sets the caching mode for this cache.

      Available modes:

      Parameters:
      value - The caching mode.
      Returns:
      This object for method chaining.
    • logOnExit

      public Cache3.Builder<K1,K2,K3,V> logOnExit(boolean value, String idValue)
      Conditionally enables logging of cache statistics when the JVM exits.

      When enabled, the cache will register a shutdown hook that logs the cache name, total cache hits, and total cache misses (size of cache) to help analyze cache effectiveness.

      Parameters:
      value - Whether to enable logging on exit.
      idValue - The identifier to use in the log message.
      Returns:
      This object for method chaining.
    • logOnExit

      public Cache3.Builder<K1,K2,K3,V> logOnExit(String value)
      Enables logging of cache statistics when the JVM exits.
      Parameters:
      value - The identifier to use in the log message.
      Returns:
      This object for method chaining.
    • maxSize

      public Cache3.Builder<K1,K2,K3,V> maxSize(int value)
      Specifies the maximum number of entries allowed in this cache.
      Parameters:
      value - The maximum number of cache entries. Must be positive.
      Returns:
      This object for method chaining.
    • supplier

      Specifies the default supplier function for computing values when keys are not found.
      Parameters:
      value - The default supplier function. Can be null.
      Returns:
      This object for method chaining.
    • threadLocal

      Enables thread-local caching.

      When enabled, each thread gets its own separate cache instance. This is useful for thread-unsafe objects that need to be cached per thread.

      This is a shortcut for wrapping a cache in a ThreadLocal, but provides a cleaner API.

      Returns:
      This object for method chaining.
      See Also:
    • weak

      public Cache3.Builder<K1,K2,K3,V> weak()
      Sets the caching mode to WEAK.

      This is a shortcut for calling cacheMode(CacheMode.WEAK).

      Weak caching uses WeakHashMap for storage, allowing cache entries to be garbage collected when keys are no longer strongly referenced elsewhere.

      Returns:
      This object for method chaining.
      See Also: