planetj.dataengine.cache
Class DataEngineCache

java.lang.Object
  |
  +--planetj.dataengine.cache.DataEngineCache

public class DataEngineCache
extends Object

Contains a group of RowCollections that have been retrieved from the database, keyed by SQLContext. By storing results retrieved from the database in the cache, applications may be able to find the results they are looking for in the cache instead of having to fetch them from the database every time.


Constructor Summary
DataEngineCache(String alias)
          Creates a DataEngineCache with a maximum size of 10000 and the specified system alias.
DataEngineCache(String alias, int maxSize)
          Creates a new DataEngineCache.
 
Method Summary
 void clear()
          Clears out the cache, removing all entries.
 void clearEstimatedSize()
          Clears the estimated size of this cache's estimated RowCollections' size.
 void close()
          Closes down this cache
 String getAlias()
          Gets the system alias associated with this cache
 List getAllKeys()
          Gets all the keys in the cache.
 List getAllValues()
          Gets all the values in this cache.
 RowCollection getCachedRowCollection(SQLContext context)
          Allow Cached RowCollections to decide if they can be used for a query.
 String getDescription()
          Gets a text description of this cache
 long getEstimatedSize()
          Gets the estimated number of bytes of all field values in this RowCollection take up.
 int getMaxSize()
          Gets the maximum number of items the cache can hold.
 int getTimeout()
          Gets the maximum number of seconds which a RowCollection can be stored in the cache and still be considered valid.
 void rowAltered(SQLContext context, ExecutingContext ec, long timestamp)
          This method is invoked when a single row is deleted, inserted, or updated.
 void setDescription(String newDescription)
          Sets a text description of this cache.
 void setTimeout(int seconds)
          Sets the maximum number of seconds which a RowCollection can be stored in the cache and still be considered valid.
 int size()
          Gets the number of items in the cache
 String toString()
          Returns the description of this cache
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataEngineCache

public DataEngineCache(String alias)
Creates a DataEngineCache with a maximum size of 10000 and the specified system alias.


DataEngineCache

public DataEngineCache(String alias,
                       int maxSize)
Creates a new DataEngineCache.

Parameters:
alias - The system alias to which the cache corresponds
maxSize - The maximum number of entries the cache can hold.
Method Detail

clear

public void clear()
Clears out the cache, removing all entries. Invoking this method under normal circumstances is probably a bad idea.


clearEstimatedSize

public void clearEstimatedSize()
Clears the estimated size of this cache's estimated RowCollections' size.


close

public void close()
Closes down this cache


getAlias

public String getAlias()
Gets the system alias associated with this cache


getAllKeys

public List getAllKeys()
Gets all the keys in the cache. The returned List is a shallow copy; if items are removed or added to it or to the cache, the other object is not affected.


getAllValues

public List getAllValues()
Gets all the values in this cache. The returend List is a shallow copy; if items are removed or added to it or to the cache, the other object is not affected.


getCachedRowCollection

public RowCollection getCachedRowCollection(SQLContext context)
Allow Cached RowCollections to decide if they can be used for a query.

Parameters:
context - The SQLContext containing the alteration information

getDescription

public String getDescription()
Gets a text description of this cache


getEstimatedSize

public long getEstimatedSize()
Gets the estimated number of bytes of all field values in this RowCollection take up.


getMaxSize

public final int getMaxSize()
Gets the maximum number of items the cache can hold. (This limitation is not currently enforced)


getTimeout

public int getTimeout()
Gets the maximum number of seconds which a RowCollection can be stored in the cache and still be considered valid. After this much time has elapsed since a RowCollection was placed in the cache, it is invalidated, and it won't able to be retrieved from the cache. Whenever a RowCollection in the cache is updated, its timer is reset, and it can wait this much time again before becoming invalid.


rowAltered

public void rowAltered(SQLContext context,
                       ExecutingContext ec,
                       long timestamp)
                throws CMException
This method is invoked when a single row is deleted, inserted, or updated. All of the RowCollections in this cache are notified so they can take appropriate action

Parameters:
context - The SQLContext containing the alteration information
ec - The current executing context
timestamp - The time associated with the alteration
CMException

setDescription

public void setDescription(String newDescription)
Sets a text description of this cache.


setTimeout

public void setTimeout(int seconds)
Sets the maximum number of seconds which a RowCollection can be stored in the cache and still be considered valid. After this much time has elapsed since a RowCollection was placed in the cache, it is invalidated, and it won't able to be retrieved from the cache. Whenever a RowCollection in the cache is updated, its timer is reset, and it can wait this much time again before becoming invalid.


size

public int size()
Gets the number of items in the cache


toString

public String toString()
Returns the description of this cache

Overrides:
toString in class Object