Package overit.geocall.cache
Class CaffeineCache
java.lang.Object
overit.geocall.cache.Cache
overit.geocall.cache.CaffeineCache
- All Implemented Interfaces:
AutoCloseable
Class that implements a cache whose entries are been stored in memory.
-
Nested Class Summary
Nested classes/interfaces inherited from class overit.geocall.cache.Cache
Cache.Info -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.github.benmanes.caffeine.cache.Cache<String, overit.geocall.cache.CaffeineCache.Views> protected static final Set<CaffeineCache> -
Constructor Summary
ConstructorsConstructorDescriptionCaffeineCache(String keyPrefix, @Nullable Cache parent) Create a new instance of the cache working with a soma-prefix keys and possibly referring a parent cacheCaffeineCache(@Nullable Cache parent) Create a new instance of the cache referred to the passed parent cache -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanclear()Clears all the cachevoidclose()Close the cache and disconnects from the parent<T,S> Item <T, S> Extracts data from cache, or fetches and caches data from the parent cache.voidfinalize()<T,S> Item <T, S> Locally retrieve the data, without search in the parent cache if the entry has not been found.Return the information about the cache's entries related to the passed key.keys()Returns the keys stored inside the cache<T,S> void Locally stores an item inside the cacheprotected booleanLocally removes a key from the cachetoString()Methods inherited from class overit.geocall.cache.Cache
checkPrefix, getKeyPrefix, getParent, getRoot, hold, invalidate, invalidate, invalidateAll, loosed, loosedAll, lose, loseAll, onInvalidation, setParent, store
-
Field Details
-
caches
-
cache
protected com.github.benmanes.caffeine.cache.Cache<String,overit.geocall.cache.CaffeineCache.Views> cache
-
-
Constructor Details
-
CaffeineCache
Create a new instance of the cache referred to the passed parent cache- Parameters:
parent- the optional parent cache used to propagate the cache changing and retrieve the missing cache values
-
CaffeineCache
Create a new instance of the cache working with a soma-prefix keys and possibly referring a parent cache- Parameters:
keyPrefix- the prefix af all the key cachedparent- the optional parent cache used to propagate the cache changing and retrieve the missing cache values
-
-
Method Details
-
fetch
Description copied from class:CacheExtracts data from cache, or fetches and caches data from the parent cache. If the parent cache is missing it can use theEntry.load()to load the real data.- Specified by:
fetchin classCache- Type Parameters:
T- the type of the raw data contained in the cache itemS- the type of the computed data contained in the cache item- Parameters:
entry- the cache's entry to look for- Returns:
- the data contained in cache, on the parent cache, or potentially loaded and cached
-
put
Description copied from class:CacheLocally stores an item inside the cache -
finalize
-
close
public void close()Description copied from class:CacheClose the cache and disconnects from the parent- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classCache
-
remove
Description copied from class:CacheLocally removes a key from the cache -
clear
protected boolean clear()Description copied from class:CacheClears all the cache -
toString
-
keys
Description copied from class:CacheReturns the keys stored inside the cache -
get
Description copied from class:CacheLocally retrieve the data, without search in the parent cache if the entry has not been found. -
getInfo
Description copied from class:CacheReturn the information about the cache's entries related to the passed key. Each element contains the information about a specific view for that entry.
-