|
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 |
Methods inherited from interface java.util.Map |
equals, hashCode |
Constructor Detail |
public CacheImpl(int newMaxEntries, long itemTtl, boolean enabled)
Method Detail |
public long getTtl()
getTtl
in interface Cache
public void addEntry(java.lang.Object key, java.lang.Object value)
addEntry
in interface Cache
com.beasys.commerce.foundation.cache.Cache
key
- value
- public void addEntry(java.lang.Object key, java.lang.Object value, long ttl)
addEntry
in interface Cache
com.beasys.commerce.foundation.cache.Cache
key
- value
- ttl
- public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
key
- value
- public java.lang.Object put(java.lang.Object key, java.lang.Object value, long ttl)
put
in interface Cache
key
- value
- ttl
- public void enable()
enable
in interface Cache
public void disable()
disable
in interface Cache
public boolean containsEntry(java.lang.Object key)
containsEntry
in interface Cache
com.beasys.commerce.foundation.cache.Cache
key
- boolean
public java.lang.Object fetchEntry(java.lang.Object key)
fetchEntry
in interface Cache
com.beasys.commerce.foundation.cache.Cache
key
- Object
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
aKey
- Object
public void removeEntries(java.lang.Object[] keys)
public void remove(java.lang.Object[] keys)
remove
in interface Cache
keys[]
- public void removeEntry(java.lang.Object key)
removeEntry
in interface Cache
com.beasys.commerce.foundation.cache.Cache
key
- public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
key
- public boolean isFull()
isFull
in interface Cache
boolean
public boolean isEmpty()
isEmpty
in interface java.util.Map
boolean
public void resetStats()
resetStats
in interface Cache
public int getHitRate()
getHitRate
in interface Cache
public int getEntryCount()
getEntryCount
in interface Cache
public void removeAllEntries()
removeAllEntries
in interface Cache
public void setMaxEntries(int newMaxEntries)
setMaxEntries
in interface Cache
public int getMaxEntries()
getMaxEntries
in interface Cache
int
public void setTtl(long newTtl)
setTtl
in interface Cache
public long getHitCount()
getHitCount
in interface Cache
long
public long getMissCount()
getMissCount
in interface Cache
long
public boolean isEnabled()
Cache
isEnabled
in interface Cache
com.beasys.commerce.foundation.cache.Cache
boolean
public int size()
size
in interface java.util.Map
int
public boolean containsKey(java.lang.Object aKey)
containsKey
in interface java.util.Map
aKey
- boolean
public boolean containsValue(java.lang.Object aValue)
containsValue
in interface java.util.Map
aValue
- boolean
public void clear()
clear
in interface java.util.Map
public java.util.Collection values()
values
in interface java.util.Map
Collection
public java.util.Set keySet()
keySet
in interface java.util.Map
Set
public java.util.Set entrySet()
entrySet
in interface java.util.Map
Set
public void putAll(java.util.Map aMap)
putAll
in interface java.util.Map
aMap
-
|
BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |