|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.core.cache.CacheManager
CacheManager.java
Copyright 1999-2002 Jcorporate Ltd.
Cache Manager is a general-purpose class to handle all different kinds of caches - it provides both "ordered" caches (stored as a Vector of objects) and "unordered" caches (stored as a Hashtable). The amount of data cached can be expressed as a count of items in the specified list (e.g. cache only so many items) or limited by the amount of free memory available (e.g. don't go below 10% of available memory being free). In both cases, the cached items are removed from the cache according to how frequently they have been used (e.g. a least-frequently-used algorithm is used to drop items from the cache).
| Constructor Summary | |
CacheManager()
Default Constructor. |
|
| Method Summary | |
static void |
addItem(String dataContext,
String cacheName,
Cacheable newItem)
Adds a Cacheable item into the cache |
static void |
addItem(String dataContext,
String cacheName,
Cacheable newItem,
long expiry)
Adds an item to the cache named by parameter cacheName |
static void |
addListener(String listener,
String listenTo)
Specify a relationship between caches. |
static void |
clear(String dataContext)
Removes all cache items for a particular data context |
static void |
clear(String dataContext,
String cacheName)
Clear's the named cache. |
static void |
clearNoNotify(String dataContext)
Clears all caches in this db context but doesn't notify any listeners |
static void |
clearNoNotify(String dataContext,
String cacheName)
Clear the named cache, but don't send the remote system notifications. |
static Cache |
createCache(String dataContext,
String cacheName,
boolean ordered)
Creates a cache as specified by the parameters listed. |
static Cache |
createCache(String dataContext,
String cacheName,
boolean ordered,
int maxSize)
Creates a cache defined by whether the cache is to be ordered, it's name and it's maximum size. |
static void |
destroy()
Destroys the CacheManager. |
static void |
displayStatus()
Displays the cache status. |
static boolean |
existsCache(String dataContext,
String cacheName)
Checks to see if the cache already exists. |
static Iterator |
getAllCacheNamesIterator(String dataContext)
Get the names of all of the Caches being held for a particular context |
static CacheSystem |
getCacheSystem(String dataContext)
Retrieve the cache system appropriate for the data context |
static CacheManager |
getInstance()
Singleton instantiation. |
static Cacheable |
getItem(String dataContext,
String cacheName,
String valueKey)
Get a particular item in the cache |
static int |
getItemCount(String dataContext,
String cacheName)
Return a count of the number of items in a cache. |
static Vector |
getItems(String dataContext,
String cacheName)
Return all of the items in a cache. |
static void |
removeItem(String dataContext,
String cacheName,
Cacheable itemToRemove)
Removes an item from the cache |
static void |
removeItemNoNotify(String dataContext,
String cacheName,
Cacheable itemToRemove)
Removes an item out of the cache without notifying the cache listeners |
static void |
setItems(String dataContext,
String cacheName,
Vector itemList)
Sets a cache to have the particular items specified in itemList. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CacheManager()
| Method Detail |
public static CacheManager getInstance()
public static final CacheSystem getCacheSystem(String dataContext)
dataContext - the data context to retrieve the cache system for
public static void destroy()
public static void addItem(String dataContext,
String cacheName,
Cacheable newItem)
throws CacheException
Cacheable item into the cache
dataContext - the data context that this item is to reside in.cacheName - The name of the cache.newItem - The new item to add to the cache
CacheException - upon error inserting into the system
public static void addItem(String dataContext,
String cacheName,
Cacheable newItem,
long expiry)
throws CacheException
dataContext - The data context that this cache is forcacheName - The name of the cache to store the object innewItem - The new item to add to the cacheexpiry - The time in miliseconds that this cache item will expire
CacheException - if there's an error inserting the item into the
cache
public static void addListener(String listener,
String listenTo)
listener - The classname of the listenerlistenTo - The name of the cache to listen to.
public static void clear(String dataContext)
throws CacheException
dataContext - The data context to clear all items for.
CacheException - CacheException if there's an error clearing the
cachepublic static void clearNoNotify(String dataContext)
dataContext - The data context that this cache is mapped to
public static void clear(String dataContext,
String cacheName)
throws CacheException
dataContext - The dbContext of the cachecacheName - The name of the cache to clear
CacheException - if there's an error clearing the cache.
public static void clearNoNotify(String dataContext,
String cacheName)
dataContext - The dbContext that the cache is attached tocacheName - The name of the cache
public static Cache createCache(String dataContext,
String cacheName,
boolean ordered)
throws CacheException
dataContext - java.lang.String The data context for your appcacheName - java.lang.String the name of the cacheordered - boolean true if you want an ordered cache such as for
ValidValues
CacheException
public static Cache createCache(String dataContext,
String cacheName,
boolean ordered,
int maxSize)
throws CacheException
dataContext - java.lang.String The dbcontext that this cache is forcacheName - java.lang.String The name of the cacheordered - boolean True if you wish for an ordered cache.maxSize - The maximum size of the cache
CacheExceptionpublic static void displayStatus()
public static boolean existsCache(String dataContext,
String cacheName)
dataContext - The dbContext that this cache is hooked tocacheName - The name of the cache
public static Iterator getAllCacheNamesIterator(String dataContext)
dataContext - The dbContext to get the cache names for.
public static Cacheable getItem(String dataContext,
String cacheName,
String valueKey)
dataContext - The dbContext for this cachecacheName - The name of the cachevalueKey - The particular item within the cache to get
public static Vector getItems(String dataContext,
String cacheName)
dataContext - The dbcontext for this cachecacheName - The name of the cache to retrieve
public static int getItemCount(String dataContext,
String cacheName)
dataContext - the dbContext to retrieve from.cacheName - The name of the cache
public static void removeItem(String dataContext,
String cacheName,
Cacheable itemToRemove)
throws CacheException
dataContext - The data context for the cachecacheName - The name of the cacheitemToRemove - the key of the item to remove
CacheException
public static void removeItemNoNotify(String dataContext,
String cacheName,
Cacheable itemToRemove)
throws CacheException
dataContext - The name of the data contextcacheName - The cache nameitemToRemove - the key in the cache that has been modified
CacheException - Upon error removing the item from the cache
public static void setItems(String dataContext,
String cacheName,
Vector itemList)
throws CacheException
dataContext - The dbContext for the cachecacheName - The name of the cacheitemList - The items to set into the cache
CacheException - if there's an error setting the items.
|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||