Package org.idempiere.cache
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:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.compiere.util.CCache
cache, DEFAULT_EXPIRE_MINUTE, nullList
-
-
Constructor Summary
Constructors Constructor Description POCopyCache(String name, int initialCapacity)
POCopyCache(String name, int initialCapacity, int expireMinutes)
POCopyCache(String name, int initialCapacity, int expireMinutes, boolean distributed)
POCopyCache(String name, int initialCapacity, int expireMinutes, boolean distributed, int maxSize)
POCopyCache(String tableName, String name, int initialCapacity)
POCopyCache(String tableName, String name, int initialCapacity, boolean distributed)
POCopyCache(String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed)
POCopyCache(String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed, int maxSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
get(Object key)
V
get(Properties ctx, K key)
V
get(Properties ctx, K key, String trxName)
V
get(K key, UnaryOperator<V> copyOperator)
Get PO from cache.V
put(K key, V value)
Put valueV
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).-
Methods inherited from class org.compiere.util.CCache
addVetoableChangeListener, clear, containsKey, containsValue, entrySet, getExpireMinutes, getHit, getMaxSize, getMiss, getName, getTableName, isDistributed, isEmpty, isExpire, isReset, keySet, newRecord, putAll, remove, removeVetoableChangeListener, reset, reset, setExpireMinutes, setUsed, size, sizeNoExpire, toString, values
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
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
-
-
-
Method Detail
-
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(Properties ctx, K key)
- Parameters:
ctx
- contextkey
-- Returns:
- value for key
-
get
public V get(Properties ctx, K key, String trxName)
- Parameters:
ctx
- contextkey
-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:
- PO from cache (if there's match for key)
-
-