|
BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.beasys.commerce.foundation.cache.CacheImpl
Implementation class for a Cache. This is a native Java object that is implemented as a Singleton created by a CacheFactory object. Internally, it is a Hashtable with Objects as keys and CacheEntry objects which are Objects wrapped in doubly linked list functionality as Values. Since the Cache is of fixed size, there is no functionality to actively remove objects from the cache - they are removed passively by expiring.
TODO: This object is heavily synchronized. If performance standards dictate, the synchronization should be made more granular.
CAUTION: This data structure does not itself provide immutability of its values. In other words, it returns references to its actual objects. It is recommended that those values protect themselves from change unless that change is actually desired - remember these objects will eventually expire from the Cache.
Inner classes inherited from class java.util.Map |
java.util.Map.Entry |
Constructor Summary | |
CacheImpl(int newMaxEntries,
long itemTtl,
boolean enabled)
Create a Cache with an initial size, timeout, and enabled value. |
Method Summary | |
void |
addEntry(java.lang.Object key,
java.lang.Object value)
Deprecated. use put. |
void |
addEntry(java.lang.Object key,
java.lang.Object value,
long ttl)
Deprecated. use put |
void |
clear()
Clear. |
boolean |
containsEntry(java.lang.Object key)
Deprecated. use containsKey |
boolean |
containsKey(java.lang.Object aKey)
Determines if an entry exists in the cache. |
boolean |
containsValue(java.lang.Object aValue)
Contains value. |
void |
disable()
Disable and flush this Cache. |
void |
enable()
Enable this Cache. |
java.util.Set |
entrySet()
entrySet defined from Map interface. |
java.lang.Object |
fetchEntry(java.lang.Object key)
Deprecated. use get |
java.lang.Object |
get(java.lang.Object key)
Lookup an entry in the Cache if it is enabled. |
int |
getEntryCount()
Deprecated. |
long |
getHitCount()
Get hit count. |
int |
getHitRate()
Returns the integer percentage of requests which found a non-expired value. |
int |
getMaxEntries()
Get max entries. |
long |
getMissCount()
Get miss count. |
long |
getTtl()
Get current Time To Live value assigned to new entries. |
boolean |
isEmpty()
Is empty. |
boolean |
isEnabled()
Is enabled. |
boolean |
isFull()
Is full. |
java.util.Set |
keySet()
Implemented from map interface. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Add a new entry to the Cache if it is not already there. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value,
long ttl)
Add a new entry to the Cache, replace if already there. |
void |
putAll(java.util.Map aMap)
Put all the values of a map. |
java.lang.Object |
remove(java.lang.Object key)
Removes a single entry from the Cache if it exists. |
void |
remove(java.lang.Object[] keys)
Convenience method to iterate through an array of keys and remove all of them. |
void |
removeAllEntries()
Deprecated. use clear |
void |
removeEntries(java.lang.Object[] keys)
Deprecated. use remove |
void |
removeEntry(java.lang.Object key)
Deprecated. use remove. |
void |
resetStats()
Reset stats. |
void |
setMaxEntries(int newMaxEntries)
Size or resize this Cache. |
void |
setTtl(long newTtl)
Set the Time to Live assigned to all entries in this cache. |
int |
size()
Size of the cache. |
java.util.Collection |
values()
Values of the map. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public CacheImpl(int newMaxEntries, long itemTtl, boolean enabled)
Method Detail |
public long getTtl()
public void addEntry(java.lang.Object key, java.lang.Object value)
key
- value
- public void addEntry(java.lang.Object key, java.lang.Object value, long ttl)
key
- value
- ttl
- public java.lang.Object put(java.lang.Object key, java.lang.Object value)
key
- value
- public java.lang.Object put(java.lang.Object key, java.lang.Object value, long ttl)
key
- value
- ttl
- public void enable()
public void disable()
public boolean containsEntry(java.lang.Object key)
key
- boolean
public java.lang.Object fetchEntry(java.lang.Object key)
key
- Object
public java.lang.Object get(java.lang.Object key)
aKey
- Object
public void removeEntries(java.lang.Object[] keys)
public void remove(java.lang.Object[] keys)
keys[]
- public void removeEntry(java.lang.Object key)
key
- public java.lang.Object remove(java.lang.Object key)
key
- public boolean isFull()
boolean
public boolean isEmpty()
boolean
public void resetStats()
public int getHitRate()
public int getEntryCount()
public void removeAllEntries()
public void setMaxEntries(int newMaxEntries)
public int getMaxEntries()
int
public void setTtl(long newTtl)
public long getHitCount()
long
public long getMissCount()
long
public boolean isEnabled()
boolean
public int size()
int
public boolean containsKey(java.lang.Object aKey)
aKey
- boolean
public boolean containsValue(java.lang.Object aValue)
aValue
- boolean
public void clear()
public java.util.Collection values()
Collection
public java.util.Set keySet()
Set
public java.util.Set entrySet()
Set
public void putAll(java.util.Map aMap)
aMap
-
|
BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |