Package com.avoka.tm.util
Class MemCache
- java.lang.Object
-
- com.avoka.tm.util.MemCache
-
public class MemCache extends Object
Provides an in memory cache for high frequency read only access values. Cached values are keyed on the specified cache key and the executing service's Organization security context.
When using the memory cache ensure you do not put excessively large values in the cache which would impact the application servers memory usage.
Examples
Put Value in Cache
This examples puts a value in the cache with a 12 hour timeout (720 mins).
import com.avoka.tm.util.* String value = "some big and expensive data..." new MemCache() .setKey("Ref Data") .setTimeout(720) .setValue(value)
Get Value from Cache
This examples gets a value from the cache with a 12 hour cache timeout (720 mins).
import com.avoka.tm.util.* String value = new MemCache() .setKey("Ref Data") .setTimeout(720) .getValue()
- Since:
- 5.0.0
- See Also:
PropertyQuery
-
-
Constructor Summary
Constructors Constructor Description MemCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getValue()
Return the memory cached object, or null if not found or has expired.MemCache
setKey(String key)
Set the mem cache key parameter.MemCache
setTimeout(int timeoutMins)
Set the mem cache timeout in minutes.void
setValue(Object value)
Set the value to cache in memory with the specified key and cacheTimeout properties.
-
-
-
Method Detail
-
setKey
public MemCache setKey(String key)
Set the mem cache key parameter.- Parameters:
key
- the cache key- Returns:
- the mem cache
-
setTimeout
public MemCache setTimeout(int timeoutMins)
Set the mem cache timeout in minutes.- Parameters:
timeoutMins
- the mem cache timeout in minutes, must be a positive value.- Returns:
- the mem cache
-
getValue
public Object getValue()
Return the memory cached object, or null if not found or has expired.- Returns:
- the memory cached object, or null if not found or has expired.
-
setValue
public void setValue(Object value)
Set the value to cache in memory with the specified key and cacheTimeout properties.- Parameters:
value
- the value to set in the cache for the specified key and cacheTimeout property
-
-