|
© 2001 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 the cache 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 Cachecom.beasys.commerce.foundation.cache.Cache
public void addEntry(java.lang.Object key,
java.lang.Object value)
addEntry in interface Cachecom.beasys.commerce.foundation.cache.Cachekey - the key of the entry to createvalue - the value to associate with the key
public void addEntry(java.lang.Object key,
java.lang.Object value,
long ttl)
addEntry in interface Cachecom.beasys.commerce.foundation.cache.Cachekey - the key of the entry to createvalue - the value to associate with the keyttl - a time-to-live value for this entry
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
put in interface java.util.Mapkey - value -
public java.lang.Object put(java.lang.Object key,
java.lang.Object value,
long ttl)
put in interface Cachekey - value - ttl - public void enable()
enable in interface Cachepublic void disable()
disable in interface Cachepublic boolean containsEntry(java.lang.Object key)
containsEntry in interface Cachecom.beasys.commerce.foundation.cache.Cachekey - the entry to look forboolean, true if the entry exists in the cachepublic java.lang.Object fetchEntry(java.lang.Object key)
fetchEntry in interface Cachecom.beasys.commerce.foundation.cache.Cachekey - the key of the entry to retrieveObject the value associated with the keypublic java.lang.Object get(java.lang.Object key)
get in interface java.util.MapaKey - Objectpublic void removeEntries(java.lang.Object[] keys)
public void remove(java.lang.Object[] keys)
remove in interface Cachekeys[] - public void removeEntry(java.lang.Object key)
removeEntry in interface Cachecom.beasys.commerce.foundation.cache.Cachekey - the key of the entry to removepublic java.lang.Object remove(java.lang.Object key)
remove in interface java.util.Mapkey - public boolean isFull()
isFull in interface Cachebooleanpublic boolean isEmpty()
isEmpty in interface java.util.Mapbooleanpublic void resetStats()
resetStats in interface Cachepublic int getHitRate()
getHitRate in interface Cachepublic int getEntryCount()
getEntryCount in interface Cachepublic void removeAllEntries()
removeAllEntries in interface Cachepublic void setMaxEntries(int newMaxEntries)
setMaxEntries in interface Cachecom.beasys.commerce.foundation.cache.CachemaxEntries - the maximimum size of the cachepublic int getMaxEntries()
getMaxEntries in interface Cacheintpublic void setTtl(long newTtl)
setTtl in interface Cachecom.beasys.commerce.foundation.cache.CachettlMillis - The time-to-live, in milliseconds, of entries in the cachepublic long getHitCount()
getHitCount in interface Cachelongpublic long getMissCount()
getMissCount in interface Cachelongpublic boolean isEnabled()
CacheisEnabled in interface Cachecom.beasys.commerce.foundation.cache.Cacheboolean, true if it is enabledpublic int size()
size in interface java.util.Mapintpublic boolean containsKey(java.lang.Object aKey)
containsKey in interface java.util.MapaKey - booleanpublic boolean containsValue(java.lang.Object aValue)
containsValue in interface java.util.MapaValue - booleanpublic void clear()
clear in interface java.util.Mappublic java.util.Collection values()
values in interface java.util.MapCollectionpublic java.util.Set keySet()
keySet in interface java.util.MapSetpublic java.util.Set entrySet()
entrySet in interface java.util.MapSetpublic void putAll(java.util.Map aMap)
putAll in interface java.util.MapaMap -
|
© 2001 BEA Systems, Inc. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||