Class Memoize

java.lang.Object
wtf.metio.memoization.jdk.Memoize

public final class Memoize extends Object

Factory for lightweight wrappers that store the result of a potentially expensive function call. Each method of this class exposes two of the following features:

Default cache

The memoizer uses the default cache of this factory. Current implementation creates a new ConcurrentMap per memoizer.

Default cache key

The memoizer uses the default BiFunction or Supplier to calculate the cache key for each call. Either uses the natural key (e.g. the input itself) or one of the methods in MemoizationDefaults.

Custom cache

The memoizer uses a user-provided ConcurrentMap as its cache. It is possible to add values to the cache both before and after the memoizer was created. In case a Map subtype is provided that is not a subclass of ConcurrentMap as well, the map entries will be copied to a new ConcurrentHashMap.

Custom cache key

The memoizer uses a user-defined BiFunction or Supplier to calculate the cache key for each call. Take a look at MemoizationDefaults for a possible key functions and suppliers.

See Also: