Package com.avoka.fc.core.util
Class MemoryCache
java.lang.Object
com.avoka.fc.core.util.MemoryCache
Provides an in memory cache for frequently used values. This memory cache is intended for use in Groovy Services
where high performance read access is required to read only data sets.
Example
def key = "Address Records" def recordSet = MemoryCache.getClientObject(key) if (recordSet == null) { // Load external address records recordSet = ... // Set cache time out to 24 hours def timeoutMins = 24 * 60 MemoryCache.setClientObject(key, recordSet, timeoutMins) }
- Since:
- 4.3.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
getClientObject
(String key) Return the cached client object, or null if not defined.static Object
getGlobalObject
(String key) Return the cached global object, or null if not defined.static void
removeClientObject
(String key) Remove the the cached client object for the given key.static void
removeGlobalObject
(String key) Remove the the cached global object for the given key.static void
setClientObject
(String key, Object value, long timeoutMins) Put an object into the client's data security context cache.static void
setGlobalObject
(String key, Object value, long timeoutMins) Put an object into the global cache.
-
Constructor Details
-
MemoryCache
public MemoryCache()
-
-
Method Details
-
getClientObject
Return the cached client object, or null if not defined. This value will be cached in the client's data security context and will not be available to other clients.- Parameters:
key
- the cache key (required)- Returns:
- the cached client object, or null if not defined
- Throws:
SecurityException
- if client data security context could not be resolved
-
getGlobalObject
Return the cached global object, or null if not defined.- Parameters:
key
- the cache key (required)- Returns:
- the cached global object, or null if not defined
-
setClientObject
Put an object into the client's data security context cache.- Parameters:
key
- the cache key (required)value
- the value to cache (required)timeoutMins
- the cache timeout in minutes
-
setGlobalObject
Put an object into the global cache.- Parameters:
key
- the cache key (required)value
- the value to cache (required)timeoutMins
- the cache timeout in minutes
-
removeClientObject
Remove the the cached client object for the given key.- Parameters:
key
- the cache key (required)
-
removeGlobalObject
Remove the the cached global object for the given key.- Parameters:
key
- the cache key (required)
-