Class DefaultMemoizingSupplier<T>

java.lang.Object
io.fluxcapacitor.common.DefaultMemoizingSupplier<T>
Type Parameters:
T - the type of the value supplied and memoized
All Implemented Interfaces:
MemoizingSupplier<T>, Supplier<T>

public class DefaultMemoizingSupplier<T> extends Object implements MemoizingSupplier<T>
A default implementation of the MemoizingSupplier interface that memoizes (caches) the result of a computation performed by a supplied Supplier.

The result is computed the first time get() is called and then cached for subsequent calls until explicitly cleared with clear(). This implementation also supports an optional expiration duration for the cached value.

  • Constructor Details

    • DefaultMemoizingSupplier

      public DefaultMemoizingSupplier(Supplier<T> delegate)
    • DefaultMemoizingSupplier

      public DefaultMemoizingSupplier(Supplier<T> delegate, Duration lifespan, Clock clock)
  • Method Details