src.server
Class Cache

java.lang.Object
  extended bysrc.server.Cache

public class Cache
extends java.lang.Object

The cache handling in the server is based on connecting ModuleQuery:s with OutputPackages. That is connecting the query that would have been sent to the module to the output package that would have been produced by the module. Last updated $Date: 2005/08/09 21:00:21 $ by $Author: andreas $ Changelog: $Log: Cache.html,v $ Revision 1.1.1.1 2005/08/09 21:00:21 andreas Initial entry Revision 1.10 2005/05/07 21:52:07 andreas Removed some debug code that I forgot to remove. Revision 1.9 2005/05/07 21:49:14 andreas Removed all scrap parameters from the cache storage (gives higher cache hitrate). Revision 1.8 2005/05/02 16:19:51 andreas Removed some debug code. Revision 1.7 2005/05/02 15:12:40 andreas Fixed a small class cast thing. Revision 1.6 2005/05/01 17:11:03 andreas Now also stores the userId of the cached query. Revision 1.5 2005/04/28 10:17:17 linus Fixed table names to be according to project standards. Revision 1.4 2005/04/28 06:55:20 andreas Removed a couple of warnings. Revision 1.3 2005/04/27 22:18:23 linus Added cache functionality. Revision 1.2 2005/04/19 09:30:48 linus Updated class documentation.

Version:
$Revision: 1.1.1.1 $ TODO
Author:
linus

Constructor Summary
Cache()
          Constructor
 
Method Summary
 void addCache(ModuleQuery query, OutputPackage result)
          Add an query / result to the cache.
 OutputPackage getCache(ModuleQuery query)
          Get the cached output package of the given ModuleQuery.
 long getCacheAge(ModuleQuery query)
          Get the age of the stored cache for a specified query.
 java.lang.String getCachedUserId(ModuleQuery query)
          Gets the userId of the cached query.
 void removeCache(ModuleQuery query)
          Removes a given query from the cache, this may happen for example when the module invalidates the cache.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cache

public Cache()
Constructor

Method Detail

getCacheAge

public long getCacheAge(ModuleQuery query)
Get the age of the stored cache for a specified query.

Parameters:
query - The query to check for the stored
Returns:
long The age of the cache or -1 if no cache was found.

getCache

public OutputPackage getCache(ModuleQuery query)
Get the cached output package of the given ModuleQuery.

Parameters:
query - The query to fetch the cached output for.
Returns:
OutputPackage The package which was cached or null if no cache was found.

getCachedUserId

public java.lang.String getCachedUserId(ModuleQuery query)
Gets the userId of the cached query.

Parameters:
query - The user's query.
Returns:
An user id or an empty string if none were found.

addCache

public void addCache(ModuleQuery query,
                     OutputPackage result)
Add an query / result to the cache. This puts the given query and result into the cache associating a time with them.

Parameters:
query - The query to put into the cache.
result - The result (from the module) to associate with the given query.
Returns:
A boolean indicating wheter or not the addition into the cache was successfull.

removeCache

public void removeCache(ModuleQuery query)
Removes a given query from the cache, this may happen for example when the module invalidates the cache.

Parameters:
query - The query to remove from the cache.