Class POCopyCache<K,V extends PO>

java.lang.Object
org.compiere.util.CCache<K,V>
org.idempiere.cache.POCopyCache<K,V>
All Implemented Interfaces:
Serializable, Map<K,V>, CacheInterface
Direct Known Subclasses:
IntPOCopyCache

public class POCopyCache<K,V extends PO> extends CCache<K,V>
Thread safe PO cache using copy on read and copy on write strategy.
Author:
hengsin
See Also:
  • Constructor Details

    • POCopyCache

      public POCopyCache(String name, int initialCapacity, int expireMinutes, boolean distributed, int maxSize)
      Parameters:
      name -
      initialCapacity -
      expireMinutes -
      distributed -
      maxSize -
    • POCopyCache

      public POCopyCache(String name, int initialCapacity, int expireMinutes, boolean distributed)
      Parameters:
      name -
      initialCapacity -
      expireMinutes -
      distributed -
    • POCopyCache

      public POCopyCache(String name, int initialCapacity, int expireMinutes)
      Parameters:
      name -
      initialCapacity -
      expireMinutes -
    • POCopyCache

      public POCopyCache(String name, int initialCapacity)
      Parameters:
      name -
      initialCapacity -
    • POCopyCache

      public POCopyCache(String tableName, String name, int initialCapacity, boolean distributed)
      Parameters:
      tableName -
      name -
      initialCapacity -
      distributed -
    • POCopyCache

      public POCopyCache(String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed, int maxSize)
      Parameters:
      tableName -
      name -
      initialCapacity -
      expireMinutes -
      distributed -
      maxSize -
    • POCopyCache

      public POCopyCache(String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed)
      Parameters:
      tableName -
      name -
      initialCapacity -
      expireMinutes -
      distributed -
    • POCopyCache

      public POCopyCache(String tableName, String name, int initialCapacity)
      Parameters:
      tableName -
      name -
      initialCapacity -
  • Method Details

    • put

      public V put(K key, V value)
      Description copied from class: CCache
      Put value
      Specified by:
      put in interface Map<K,V extends PO>
      Overrides:
      put in class CCache<K,V extends PO>
      Parameters:
      key - key
      value - value
      Returns:
      previous value
    • put

      public V put(K key, V po, UnaryOperator<V> copyOperator)
      A copy of the PO will be created and add to cache using copyOperator or through copy constructor (through reflection) if copyOperator parameter is null (exception is throw if both copyOperator and copy constructor is not available).
      Parameters:
      key -
      po -
      copyOperator - operator to call copy constructor
      Returns:
      PO added to cache
    • get

      public V get(Object key)
      Specified by:
      get in interface Map<K,V extends PO>
      Overrides:
      get in class CCache<K,V extends PO>
      See Also:
    • get

      public V get(Properties ctx, K key)
      Get a copy of PO from cache using copy constructor
      Parameters:
      ctx - context
      key -
      Returns:
      value for key
    • get

      public V get(Properties ctx, K key, String trxName)
      Get a copy of PO from cache using copy constructor
      Parameters:
      ctx - context
      key -
      trxName -
      Returns:
      value for key
    • get

      public V get(K key, UnaryOperator<V> copyOperator)
      Get PO from cache. A copy of the cached PO is return
      Parameters:
      key -
      copyOperator - operator to call copy constructor
      Returns:
      copy of PO from cache (if there's match for key)