Package com.avoka.fc.core.util
Class MemoryCache
- java.lang.Object
-
- com.avoka.fc.core.util.MemoryCache
-
public class MemoryCache extends Object
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
Constructors Constructor Description MemoryCache()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.
-
-
-
Method Detail
-
getClientObject
public static Object getClientObject(String key)
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
public static Object getGlobalObject(String key)
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
public static void setClientObject(String key, Object value, long timeoutMins)
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
public static void setGlobalObject(String key, Object value, long timeoutMins)
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
public static void removeClientObject(String key)
Remove the the cached client object for the given key.- Parameters:
key
- the cache key (required)
-
removeGlobalObject
public static void removeGlobalObject(String key)
Remove the the cached global object for the given key.- Parameters:
key
- the cache key (required)
-
-