Package overit.geocall.cache
Class RedisCache
java.lang.Object
overit.geocall.cache.Cache
overit.geocall.cache.RedisCache
- All Implemented Interfaces:
AutoCloseable
Implementation of a cached based on Redis server; All the entries will
be saved and retrieved to and from a remote Redis server.
-
Nested Class Summary
Nested classes/interfaces inherited from class overit.geocall.cache.Cache
Cache.Info -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRedisCache(String keyPrefix, RedisDB rdb) Create cache that leverages the passed redis database to store and retrieve the cached values -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanclear()Clears all the cache<T,S> Item <T, S> Extracts data from cache, or fetches and caches data from the parent cache.<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 cacheMethods inherited from class overit.geocall.cache.Cache
checkPrefix, close, finalize, getKeyPrefix, getParent, getRoot, hold, invalidate, invalidate, invalidateAll, loosed, loosedAll, lose, loseAll, onInvalidation, setParent, store
-
Field Details
-
rdb
-
mustWrite
protected boolean mustWrite
-
-
Constructor Details
-
RedisCache
Create cache that leverages the passed redis database to store and retrieve the cached values- Parameters:
keyPrefix- the prefix af all the key cachedrdb- redis database's connector instance
-
-
Method Details
-
remove
Locally removes a key from the cache
If the remove has been success, it notify all the remote listeners -
put
Locally stores an item inside the cache
If the put has been success, it notify all the remote listeners -
clear
protected boolean clear()Clears all the cache
If the clear has been success, it notify all the remote listeners -
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
-
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.
-