Package net.solarnetwork.central.support
Interface SharedValueCache<K,V,S>
- All Known Implementing Classes:
BasicSharedValueCache
public interface SharedValueCache<K,V,S>
Cache API where cached values are shared on a secondary key.
The idea for this API is for situations where it is desirable to cache a common value that is expensive to compute, but with potentially different expiration times for different uses. Thus the expensive value can be computed once using a "shared key" but then cached multiple times with different expiration times using a primary key.
-
Method Summary
-
Method Details
-
get
Get a cached value by key.- Parameters:
key- the key of the value to get- Returns:
- the value, or null if not available (or expired)
-
put
Add a value to the cache.- Parameters:
key- the cache keyshareKey- the shared value keyvalueProvider- the cache value providerttl- the cache value time to live, in seconds- Returns:
- the value, either a shared instance or newly computed by
valueProvider
-
prune
void prune()Prune shared values no longer in use.
-