Class DataCache<T>

  • Type Parameters:
    T - Data cache type

    public class DataCache<T>
    extends java.lang.Object
    General purpose managed data cache
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  DataCache.RemoveCallback<T>
      Search callback interface
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cleanUp()
      Force clean up data cache
      void clear()
      Clear all data from cache
      T get​(java.lang.String key)
      Get data from cache
      java.util.concurrent.ConcurrentMap<java.lang.String,​T> getAll()
      Get all data from cache
      void put​(java.lang.String key, T data)
      Put data in cache
      void remove​(java.lang.String key)
      Remove data from cache
      long size()
      Get data cache size
      • Methods inherited from class java.lang.Object

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

      • DataCache

        public DataCache​(int maxSize,
                         int expiresAfter)
        Constructor
        Parameters:
        maxSize - Cache max size (<=0 means no limit)
        expiresAfter - Cache expiration delay ($gt;0 means expiration after creation, lt;0 means expiration after last access, 0 means no limit)
      • DataCache

        public DataCache​(int maxSize,
                         int expiresAfter,
                         DataCache.RemoveCallback<T> callback)
        Constructor
        Parameters:
        maxSize - Cache max size (<=0 means no limit)
        expiresAfter - Cache expiration delay ($gt;0 means expiration after creation, lt;0 means expiration after last access, 0 means no limit)
        callback - Remve callback
    • Method Detail

      • put

        public void put​(java.lang.String key,
                        T data)
        Put data in cache
        Parameters:
        key - Key
        data - Data
      • get

        public T get​(java.lang.String key)
        Get data from cache
        Parameters:
        key - Key
        Returns:
        Data or null if not found or expired
      • getAll

        public java.util.concurrent.ConcurrentMap<java.lang.String,​T> getAll()
        Get all data from cache
        Returns:
        All data
      • remove

        public void remove​(java.lang.String key)
        Remove data from cache
        Parameters:
        key - Key
      • clear

        public void clear()
        Clear all data from cache
      • size

        public long size()
        Get data cache size
      • cleanUp

        public void cleanUp()
        Force clean up data cache