Package org.idempiere.cache
Class ImmutablePOCache<K,V extends PO & ImmutablePOSupport>
java.lang.Object
org.compiere.util.CCache<K,V>
org.idempiere.cache.ImmutablePOCache<K,V>
- All Implemented Interfaces:
Serializable
,Map<K,
,V> CacheInterface
- Direct Known Subclasses:
ImmutableIntPOCache
Thread safe PO cache. For thread safety, only PO with thread local context (po.getCtx() == Env.getCtx() and without trxName is keep in cache.
PO is mark immutable before being added to cache. If the pass in PO doesn't match the 2 condition, a copy of the PO is added to cache instead.
For get operation, if request is being make with non thread local context (ctx != Env.getCtx()) or with trxName, a copy of the PO from cache is return instead.
PO is mark immutable before being added to cache. If the pass in PO doesn't match the 2 condition, a copy of the PO is added to cache instead.
For get operation, if request is being make with non thread local context (ctx != Env.getCtx()) or with trxName, a copy of the PO from cache is return instead.
- Author:
- hengsin
- See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.compiere.util.CCache
cache, DEFAULT_EXPIRE_MINUTE, nullList
-
Constructor Summary
ConstructorDescriptionImmutablePOCache
(String name, int initialCapacity) ImmutablePOCache
(String name, int initialCapacity, int expireMinutes) ImmutablePOCache
(String name, int initialCapacity, int expireMinutes, boolean distributed) ImmutablePOCache
(String name, int initialCapacity, int expireMinutes, boolean distributed, int maxSize) ImmutablePOCache
(String tableName, String name, int initialCapacity) ImmutablePOCache
(String tableName, String name, int initialCapacity, boolean distributed) ImmutablePOCache
(String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed) ImmutablePOCache
(String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed, int maxSize) -
Method Summary
Modifier and TypeMethodDescriptionget
(Properties ctx, K key) get
(Properties ctx, K key, UnaryOperator<V> copyOperator) Get PO from cache.Put valueput
(K key, V po, UnaryOperator<V> copyOperator) PO is mark immutable and add to cache if it is without trxName and with thread local context (i.e po.getCtx() == Env.getCtx()).
If either of the condition is not true, a copy of the PO will be created and add to cache using the pass in 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 Details
-
ImmutablePOCache
public ImmutablePOCache(String name, int initialCapacity, int expireMinutes, boolean distributed, int maxSize) - Parameters:
name
-initialCapacity
-expireMinutes
-distributed
-maxSize
-
-
ImmutablePOCache
- Parameters:
name
-initialCapacity
-expireMinutes
-distributed
-
-
ImmutablePOCache
- Parameters:
name
-initialCapacity
-expireMinutes
-
-
ImmutablePOCache
- Parameters:
name
-initialCapacity
-
-
ImmutablePOCache
- Parameters:
tableName
-name
-initialCapacity
-distributed
-
-
ImmutablePOCache
public ImmutablePOCache(String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed, int maxSize) - Parameters:
tableName
-name
-initialCapacity
-expireMinutes
-distributed
-maxSize
-
-
ImmutablePOCache
public ImmutablePOCache(String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed) - Parameters:
tableName
-name
-initialCapacity
-expireMinutes
-distributed
-
-
ImmutablePOCache
- Parameters:
tableName
-name
-initialCapacity
-
-
-
Method Details
-
put
Description copied from class:CCache
Put value -
put
PO is mark immutable and add to cache if it is without trxName and with thread local context (i.e po.getCtx() == Env.getCtx()).
If either of the condition is not true, a copy of the PO will be created and add to cache using the pass in 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 if po has transaction name or po.getCtx() != Env.getCtx()- Returns:
- po or the copy of po that have been added to cache
-
get
-
get
- Parameters:
ctx
- contextkey
-- Returns:
- value for key
-
get
Get PO from cache. If ctx != Env.getCtx() or trxName is not empty, a copy of the PO is return instead- Parameters:
ctx
- contextkey
-copyOperator
- operator to call copy constructor when ctx != po.getCtx() or transaction name is not empty- Returns:
- PO from cache (if there's match for key)
-