Class MemCache


  • public class MemCache
    extends java.lang.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
      java.lang.Object getValue()
      Return the memory cached object, or null if not found or has expired.
      MemCache setKey​(java.lang.String key)
      Set the mem cache key parameter.
      MemCache setTimeout​(int timeoutMins)
      Set the mem cache timeout in minutes.
      void setValue​(java.lang.Object value)
      Set the value to cache in memory with the specified key and cacheTimeout properties.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MemCache

        public MemCache()
    • Method Detail

      • setKey

        public MemCache setKey​(java.lang.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 java.lang.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​(java.lang.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