Class CachedSupplier<T>

  • All Implemented Interfaces:
    java.util.function.Supplier<T>

    public class CachedSupplier<T>
    extends java.lang.Object
    implements java.util.function.Supplier<T>
    Supplier that caches the value for a given duration with ability to invalidate on demand. Is thread safe.
    Author:
    freva
    • Constructor Summary

      Constructors 
      Constructor Description
      CachedSupplier​(java.util.function.Supplier<T> delegate, java.time.Duration period)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T get()  
      void invalidate()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CachedSupplier

        public CachedSupplier​(java.util.function.Supplier<T> delegate,
                              java.time.Duration period)
    • Method Detail

      • get

        public T get()
        Specified by:
        get in interface java.util.function.Supplier<T>
      • invalidate

        public void invalidate()