Class CCache<K,​V>

    • Field Detail

      • cache

        protected Map<K,​V> cache
      • nullList

        protected Set<K> nullList
      • DEFAULT_EXPIRE_MINUTE

        public static final int DEFAULT_EXPIRE_MINUTE
        Default cache expire time in minutes
    • Constructor Detail

      • CCache

        public CCache​(String name,
                      int initialCapacity)
      • CCache

        public CCache​(String name,
                      int initialCapacity,
                      int expireMinutes)
      • CCache

        public CCache​(String name,
                      int initialCapacity,
                      int expireMinutes,
                      boolean distributed)
      • CCache

        public CCache​(String name,
                      int initialCapacity,
                      int expireMinutes,
                      boolean distributed,
                      int maxSize)
      • CCache

        public CCache​(String tableName,
                      String name,
                      int initialCapacity)
        Adempiere Cache - expires after 2 hours
        Parameters:
        name - (table) name of the cache
        initialCapacity - initial capacity
      • CCache

        public CCache​(String tableName,
                      String name,
                      int initialCapacity,
                      boolean distributed)
      • CCache

        public CCache​(String tableName,
                      String name,
                      int initialCapacity,
                      int expireMinutes,
                      boolean distributed)
      • CCache

        public CCache​(String tableName,
                      String name,
                      int initialCapacity,
                      int expireMinutes,
                      boolean distributed,
                      int maxSize)
        Adempiere Cache
        Parameters:
        name - (table) name of the cache
        initialCapacity - initial capacity
        expireMinutes - expire after minutes (0=no expire)
        distributed -
        maxSize - ignore if distributed=true
    • Method Detail

      • getName

        public String getName()
        Get (table) Name
        Returns:
        name
      • getTableName

        public String getTableName()
      • setExpireMinutes

        public void setExpireMinutes​(int expireMinutes)
        Set Expire Minutes and start it
        Parameters:
        expireMinutes - minutes or 0
      • getExpireMinutes

        public int getExpireMinutes()
        Get Expire Minutes
        Returns:
        expire minutes
      • isReset

        public boolean isReset()
        Cache was reset
        Returns:
        true if reset
      • setUsed

        public void setUsed()
        Resets the Reset flag
      • toString

        public String toString()
        String Representation
        Overrides:
        toString in class Object
        Returns:
        info
      • clear

        public void clear()
        Clear cache and calculate new expiry time
        Specified by:
        clear in interface Map<K,​V>
        See Also:
        Map.clear()
      • put

        public V put​(K key,
                     V value)
        Put value
        Specified by:
        put in interface Map<K,​V>
        Parameters:
        key - key
        value - value
        Returns:
        previous value
      • putAll

        public void putAll​(Map<? extends K,​? extends V> m)
        Put All
        Specified by:
        putAll in interface Map<K,​V>
        Parameters:
        m - map
      • keySet

        public Set<K> keySet()
        The return key set excludes key that map to null value
        Specified by:
        keySet in interface Map<K,​V>
        See Also:
        Map.keySet()
      • sizeNoExpire

        public int sizeNoExpire()
        Get Size w/o Expire
        Returns:
        size
        See Also:
        Map.size()
      • addVetoableChangeListener

        public void addVetoableChangeListener​(VetoableChangeListener listener)
        Add Vetoable Change Listener
        Parameters:
        listener - listner
      • removeVetoableChangeListener

        public void removeVetoableChangeListener​(VetoableChangeListener listener)
        Remove Vetoable Change Listener
        Parameters:
        listener - listener
      • remove

        public V remove​(Object key)
        Specified by:
        remove in interface Map<K,​V>
      • reset

        public int reset​(int recordId)
        Description copied from interface: CacheInterface
        Reset Cache by record id
        Specified by:
        reset in interface CacheInterface
        Returns:
        number of items reset
      • newRecord

        public void newRecord​(int record_ID)
        Description copied from interface: CacheInterface
        New record created notification
        Specified by:
        newRecord in interface CacheInterface
      • getMaxSize

        public int getMaxSize()
        Returns:
        max size of cache
      • isDistributed

        public boolean isDistributed()
        Returns:
        true if cache is distributed (using hazelcast)
      • getHit

        public long getHit()
        Returns:
        cache hit count
      • getMiss

        public long getMiss()
        Returns:
        cache miss count
      • isExpire

        public boolean isExpire()
        Returns:
        true if cache has expire