Package oshi.util
Class Memoizer
java.lang.Object
oshi.util.Memoizer
A memoized function stores the output corresponding to some set of specific inputs. Subsequent calls with remembered
inputs return the remembered result rather than recalculating it.
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
Default exipiration of memoized values in nanoseconds, which will refresh after this time elapses.static <T> Supplier<T>
Store a supplier in a delegate function to be computed only once.static <T> Supplier<T>
Store a supplier in a delegate function to be computed once, and only again after time to live (ttl) has expired.
-
Method Details
-
defaultExpiration
public static long defaultExpiration()Default exipiration of memoized values in nanoseconds, which will refresh after this time elapses. Update by settingGlobalConfig
propertyoshi.util.memoizer.expiration
to a value in milliseconds.- Returns:
- The number of nanoseconds to keep memoized values before refreshing
-
memoize
Store a supplier in a delegate function to be computed once, and only again after time to live (ttl) has expired.- Type Parameters:
T
- The type of object supplied- Parameters:
original
- TheSupplier
to memoizettlNanos
- Time in nanoseconds to retain calculation. If negative, retain indefinitely.- Returns:
- A memoized version of the supplier
-
memoize
Store a supplier in a delegate function to be computed only once.- Type Parameters:
T
- The type of object supplied- Parameters:
original
- TheSupplier
to memoize- Returns:
- A memoized version of the supplier
-