Package com.sun.appserv.util.cache
Interface Cache
-
- All Known Subinterfaces:
EJBObjectCache
- All Known Implementing Classes:
BaseCache,BoundedMultiLruCache,FIFOEJBObjectCache,FIFOSessionCache,LruCache,LruEJBCache,LruSessionCache,MultiLruCache,NRUSessionCache,UnboundedEJBObjectCache,UnBoundedSessionCache
public interface CacheCache Generic cache interface
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadd(Object key, Object value)add the given value to the cache at the specified keyvoidadd(Object key, Object value, int size)add the given value with specified size to the cache at specified keyvoidaddCacheListener(CacheListener listener)add the cache module listenerintclear()clear all the entries from the cache.voidclearStats()clear all statsbooleancontains(Object key)check if the cache contains the item at the keyvoiddestroy()Destroys this cache.Enumerationelements()get an Enumeration for the keys stored in the cacheObjectget(Object key)get the item stored at the key.IteratorgetAll(Object key)get all the items with the given key.intgetEntryCount()get the number of entries in the cacheintgetIndex(Object key)get the index of the item given a keyObjectgetStatByName(String key)get the desired statistic counterMapgetStats()get the stats snapshotvoidinit(int maxEntries, float loadFactor, Properties props)initialize the cachevoidinit(int maxEntries, Properties props)initialize the cache with the default load factor (0.75)booleanisEmpty()is this cache empty?Iteratorkeys()get an Iterator for the keys stored in the cachevoidnotifyRefresh(int index)notify threads waiting for a refresh on the object associated with the keyObjectput(Object key, Object value)cache the given value at the specified key and return previous valueObjectput(Object key, Object value, int size)cache the given value at the specified key and return previous valueObjectremove(Object key)remove the item with the given key.Objectremove(Object key, Object value)remove the given value stored at the key.voidremoveAll(Object key)remove all the item with the given key.voidtrimExpiredEntries(int maxCount)trim the expired entries from the cache.Iteratorvalues()get an Iterator for the values stored in the cachebooleanwaitRefresh(int index)wait for a refresh on the object associated with the key
-
-
-
Method Detail
-
init
void init(int maxEntries, float loadFactor, Properties props) throws Exceptioninitialize the cache- Parameters:
maxEntries- maximum number of entries expected in the cacheloadFactor- the load factorprops- opaque list of properties for a given cache implementation- Throws:
a- generic Exception if the initialization failedException
-
init
void init(int maxEntries, Properties props) throws Exceptioninitialize the cache with the default load factor (0.75)- Parameters:
maxEntries- maximum number of entries expected in the cacheprops- opaque list of properties for a given cache implementation- Throws:
a- generic Exception if the initialization failedException
-
addCacheListener
void addCacheListener(CacheListener listener)
add the cache module listener- Parameters:
listener-CacheListenerimplementation
-
getIndex
int getIndex(Object key)
get the index of the item given a key- Parameters:
key- of the entry- Returns:
- the index to be used in the cache
-
getAll
Iterator getAll(Object key)
get all the items with the given key.- Parameters:
key- lookup key
-
contains
boolean contains(Object key)
check if the cache contains the item at the key- Parameters:
key- lookup key
-
keys
Iterator keys()
get an Iterator for the keys stored in the cache
-
elements
Enumeration elements()
get an Enumeration for the keys stored in the cache
-
values
Iterator values()
get an Iterator for the values stored in the cache
-
put
Object put(Object key, Object value)
cache the given value at the specified key and return previous value- Parameters:
key- lookup keyobject- item value to be stored
-
put
Object put(Object key, Object value, int size)
cache the given value at the specified key and return previous value- Parameters:
key- lookup keyobject- item value to be storedsize- in bytes of the value being cached
-
add
void add(Object key, Object value)
add the given value to the cache at the specified key- Parameters:
key- lookup keyobject- item value to be stored This function is suitable for multi-valued keys.
-
add
void add(Object key, Object value, int size)
add the given value with specified size to the cache at specified key- Parameters:
key- lookup keyobject- item value to be storedsize- in bytes of the value being added This function is suitable for multi-valued keys.
-
remove
Object remove(Object key, Object value)
remove the given value stored at the key.- Parameters:
key- lookup keyvalue- to match (for multi-valued keys)
-
removeAll
void removeAll(Object key)
remove all the item with the given key.- Parameters:
key- lookup key
-
waitRefresh
boolean waitRefresh(int index)
wait for a refresh on the object associated with the key- Parameters:
index- index of the entry. The index must be obtained via one of thegetIndex()methods.
-
notifyRefresh
void notifyRefresh(int index)
notify threads waiting for a refresh on the object associated with the key- Parameters:
index- index of the entry. The index must be obtained via one of thegetIndex()methods.
-
clear
int clear()
clear all the entries from the cache.
-
isEmpty
boolean isEmpty()
is this cache empty?
-
getEntryCount
int getEntryCount()
get the number of entries in the cache- Returns:
- the number of entries the cache currently holds
-
getStatByName
Object getStatByName(String key)
get the desired statistic counter- Parameters:
key- to corresponding stat- Returns:
- an Object corresponding to the stat See also: Constant.java for the key
-
getStats
Map getStats()
get the stats snapshot- Returns:
- a Map of stats See also: Constant.java for the keys
-
clearStats
void clearStats()
clear all stats
-
trimExpiredEntries
void trimExpiredEntries(int maxCount)
trim the expired entries from the cache.- Parameters:
maxCount- maximum number of invalid entries to trim specify Integer.MAX_VALUE to trim all timedout entries This call is to be scheduled by a thread managed by the container.
-
destroy
void destroy()
Destroys this cache. This method should perform final clean ups.
-
-