Interface LocalCache
- 
public interface LocalCache
Framework service injectable in components or services methods to handle local caching. Useful for actions when deployed in a long running instance when actions are costly. 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceLocalCache.ElementUse to enrich object with meta-data (help to choice if attached object has to be removed from cache) 
- 
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> TcomputeIfAbsent(Class<T> expectedClass, String key, long timeoutMs, Supplier<T> value)Read or compute and save a value for a determined duration.<T> TcomputeIfAbsent(Class<T> expectedClass, String key, Predicate<LocalCache.Element> toRemove, long timeoutMs, Supplier<T> value)Read or compute and save a value for a determined duration and predicate.<T> TcomputeIfAbsent(Class<T> expectedClass, String key, Predicate<LocalCache.Element> toRemove, Supplier<T> value)Read or compute and save a value until remove predicate go to remove.<T> TcomputeIfAbsent(Class<T> expectedClass, String key, Supplier<T> value)Compute and save a value, if key not present, for undetermined duration.voidevict(String key)Remove a cached entry.voidevictIfValue(String key, Object expected)Remove a cached entry if a particular value is in the cache. 
 - 
 
- 
- 
Method Detail
- 
computeIfAbsent
<T> T computeIfAbsent(Class<T> expectedClass, String key, Predicate<LocalCache.Element> toRemove, long timeoutMs, Supplier<T> value)
Read or compute and save a value for a determined duration and predicate.- Type Parameters:
 T- class of cached instance.- Parameters:
 expectedClass- : cached instance class.key- : the cache key, must be unique accross the server.toRemove- : is the object to be removed.timeoutMs- : duration of cache value.value- : the value provider if the cache get does a miss.- Returns:
 - the cached or newly computed value.
 
 
- 
computeIfAbsent
<T> T computeIfAbsent(Class<T> expectedClass, String key, Predicate<LocalCache.Element> toRemove, Supplier<T> value)
Read or compute and save a value until remove predicate go to remove.- Type Parameters:
 T- class of cached instance.- Parameters:
 expectedClass- : cached instance class.key- : the cache key, must be unique accross the server.toRemove- : is the object to be removed.value- : the value provider if the cache get does a miss.- Returns:
 - the cached or newly computed value.
 
 
- 
computeIfAbsent
<T> T computeIfAbsent(Class<T> expectedClass, String key, long timeoutMs, Supplier<T> value)
Read or compute and save a value for a determined duration.- Type Parameters:
 T- class of cached instance.- Parameters:
 expectedClass- : cached instance class.key- : the cache key, must be unique accross the server.timeoutMs- : duration of cache value.value- : value provider.- Returns:
 - the cached or newly computed value.
 
 
- 
computeIfAbsent
<T> T computeIfAbsent(Class<T> expectedClass, String key, Supplier<T> value)
Compute and save a value, if key not present, for undetermined duration.- Type Parameters:
 T- class of cached instance.- Parameters:
 expectedClass- : cached instance class.key- : the cache key, must be unique accross the server.value- : value provider.- Returns:
 - the cached or newly computed value.
 
 
- 
evictIfValue
void evictIfValue(String key, Object expected)
Remove a cached entry if a particular value is in the cache.- Parameters:
 key- key to evict.expected- expected value activating the eviction.
 
 - 
 
 -