Class Cache<T>

java.lang.Object
liquibase.util.Cache<T>

public class Cache<T> extends Object
A wrapper around a method which is expected to be called multiple times. This class orchestrates ensuring that the method is called once and storing the result value for subsequent executions, with support for time-to-live (TTL). Some of the logic in this class is borrowed from the Guava implementation of ExpiringMemoizingSupplier: https://github.com/google/guava/blob/cc2c5d3d6623fe66a969c29fcb422bf02fb57a1f/guava/src/com/google/common/base/Suppliers.java#L286-L346
  • Constructor Details

    • Cache

      public Cache(Callable<T> generator)
    • Cache

      public Cache(Callable<T> generator, boolean exceptionIsPermitted)
    • Cache

      public Cache(Callable<T> generator, boolean exceptionIsPermitted, long timeToLiveMillis)
  • Method Details

    • get

      public T get() throws Exception
      Throws:
      Exception
    • clearCache

      public void clearCache()
      Clears the cache and resets its state.