Package org.compiere.util
Class CCache<K,V>
java.lang.Object
org.compiere.util.CCache<K,V>
- Type Parameters:
K
- KeyV
- Value
- All Implemented Interfaces:
Serializable
,Map<K,
,V> CacheInterface
- Direct Known Subclasses:
ImmutablePOCache
,NaturalAccountMap
,POCopyCache
Cache for table.
- Version:
- $Id: CCache.java,v 1.2 2006/07/30 00:54:35 jjanke Exp $
- Author:
- Jorg Janke
- See Also:
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add Vetoable Change Listenervoid
clear()
Clear cache and calculate new expiry timeboolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
The return entry set exclude entries that contains null valueint
Get Expire Minuteslong
getHit()
Get cache hit countint
long
getMiss()
Get cache miss countgetName()
Get (table) NameGet table nameboolean
Is cache distributedboolean
isEmpty()
boolean
isExpire()
boolean
isReset()
Cache was resetkeySet()
The return key set excludes key that map to null valuevoid
newRecord
(int record_ID) New record created notificationPut valuevoid
Put Allvoid
Remove Vetoable Change Listenerint
reset()
Reset Cacheint
reset
(int recordId) Reset Cache by record idvoid
setExpireMinutes
(int expireMinutes) Set Expire Minutes and start itvoid
setUsed()
Resets the Reset flagint
size()
Get Size of Cacheint
Get Size w/o ExpiretoString()
String Representationvalues()
The return values collection exclude null value entriesMethods 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
-
Field Details
-
cache
Key:value map of cached items -
nullList
Set of key that has null value -
DEFAULT_EXPIRE_MINUTE
public static final int DEFAULT_EXPIRE_MINUTEDefault cache expire time in minutes
-
-
Constructor Details
-
CCache
- Parameters:
name
-initialCapacity
-
-
CCache
- Parameters:
name
-initialCapacity
-expireMinutes
-
-
CCache
- Parameters:
name
-initialCapacity
-expireMinutes
-distributed
-
-
CCache
public CCache(String name, int initialCapacity, int expireMinutes, boolean distributed, int maxSize) - Parameters:
name
-initialCapacity
-expireMinutes
-distributed
-maxSize
-
-
CCache
- Parameters:
tableName
-name
- (table) name of the cacheinitialCapacity
- initial capacity // ignored
-
CCache
- Parameters:
tableName
-name
-initialCapacity
-distributed
-
-
CCache
public CCache(String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed) - Parameters:
tableName
-name
-initialCapacity
-expireMinutes
-distributed
-
-
CCache
public CCache(String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed, int maxSize) - Parameters:
tableName
-name
- (table) name of the cacheinitialCapacity
- initial capacity // ignoredexpireMinutes
- expire after minutes (0=no expire)distributed
-maxSize
- ignore if distributed=true
-
-
Method Details
-
getName
Get (table) Name- Returns:
- name
-
getTableName
Get table name- Returns:
- table name
-
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 -
reset
public int reset()Reset Cache- Specified by:
reset
in interfaceCacheInterface
- Returns:
- number of items cleared
- See Also:
-
toString
String Representation -
clear
public void clear()Clear cache and calculate new expiry time -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V> - See Also:
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V> - See Also:
-
entrySet
The return entry set exclude entries that contains null value -
get
-
put
Put value -
putAll
Put All -
isEmpty
public boolean isEmpty() -
keySet
The return key set excludes key that map to null value -
size
public int size()Description copied from interface:CacheInterface
Get Size of Cache -
sizeNoExpire
public int sizeNoExpire()Get Size w/o Expire- Returns:
- size
- See Also:
-
values
The return values collection exclude null value entries -
addVetoableChangeListener
Add Vetoable Change Listener- Parameters:
listener
- listner
-
removeVetoableChangeListener
Remove Vetoable Change Listener- Parameters:
listener
- listener
-
remove
-
reset
public int reset(int recordId) Description copied from interface:CacheInterface
Reset Cache by record id- Specified by:
reset
in interfaceCacheInterface
- 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 interfaceCacheInterface
-
getMaxSize
public int getMaxSize()- Returns:
- max size of cache
-
isDistributed
public boolean isDistributed()Is cache distributed- Returns:
- true if cache is distributed (using hazelcast)
-
getHit
public long getHit()Get cache hit count- Returns:
- cache hit count
-
getMiss
public long getMiss()Get cache miss count- Returns:
- cache miss count
-
isExpire
public boolean isExpire()- Returns:
- true if cache has expire
-