Interface AsCacheStrategy
- All Known Implementing Classes:
DefaultAsCacheStrategy
public interface AsCacheStrategy
Abstraction for interactions with the cache.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the cache by removing all cached entries.longgetHits()Returns the hit count.longReturns the miss count.longgetSize()Returns number of elements currently in the cache.<V> VgetWithLoader(AsCacheKey cacheKey, Function<AsCacheKey, V> valueLoader) Returns the value in the cache for the given key.booleanisEnabled(AsCacheScope cacheScope) Checks if the cache is enabled for the givenAsCacheScope.
-
Method Details
-
isEnabled
Checks if the cache is enabled for the givenAsCacheScope.- Returns:
trueif the cache is enabled,falseotherwise
-
getWithLoader
Returns the value in the cache for the given key. If the key is null or the value is not yet in the cache, valueLoader will be used to load the missing value.- Parameters:
cacheKey- - the cache keyvalueLoader- - function to load values- Returns:
- the cached value
-
clear
void clear()Clears the cache by removing all cached entries. -
getSize
long getSize()Returns number of elements currently in the cache. -
getHits
long getHits()Returns the hit count. -
getMisses
long getMisses()Returns the miss count.
-