org.objectweb.cjdbc.controller.cache.result.rules
Class RelaxedCaching

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.cache.result.CacheBehavior
      extended byorg.objectweb.cjdbc.controller.cache.result.rules.RelaxedCaching

public class RelaxedCaching
extends CacheBehavior

RelaxedCaching means we set a timeout value for this entry, and when expired we keep in the cache if no write has modified the corresponding result, we wait for the same amount of time again. RelaxedCaching may provide stale data. The timeout defines the maximum staleness of a cache entry. It means that the cache may return an entry that is out of date. timeout: is a value in seconds and 0 means no timeout (always in the cache) keepIfNotDirty: if true the entry is kept in the cache and the timeout is reset, if false, the entry is removed from the cache after the timeout has expired even if the entry was not affected by a write.

Version:
1.0
Author:
Nicolas Modrzyk , Emmanuel Cecchet

Field Summary
private  boolean keepIfNotDirty
           
private  long timeout
           
 
Fields inherited from class org.objectweb.cjdbc.controller.cache.result.CacheBehavior
 
Constructor Summary
RelaxedCaching(boolean keepIfNotDirty, long timeout)
          Create new RelaxedCaching action
 
Method Summary
 AbstractResultCacheEntry getCacheEntry(SelectRequest sqlQuery, ControllerResultSet result, AbstractResultCache cache)
          Builds a cache entry from a SelectRequest and a ControllerResultSet.
 java.lang.String getXml()
          Implementation specific xml dump of the cache behavior.
 
Methods inherited from class org.objectweb.cjdbc.controller.cache.result.CacheBehavior
getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeout

private long timeout

keepIfNotDirty

private boolean keepIfNotDirty
Constructor Detail

RelaxedCaching

public RelaxedCaching(boolean keepIfNotDirty,
                      long timeout)
Create new RelaxedCaching action

Parameters:
timeout - before we check the validity of an entry
keepIfNotDirty - true if non-dirty entries must be kept in the cache
Method Detail

getCacheEntry

public AbstractResultCacheEntry getCacheEntry(SelectRequest sqlQuery,
                                              ControllerResultSet result,
                                              AbstractResultCache cache)
Description copied from class: CacheBehavior
Builds a cache entry from a SelectRequest and a ControllerResultSet. This cache entry can then be inserted in the cache.

Specified by:
getCacheEntry in class CacheBehavior
Parameters:
sqlQuery - entry to add in the cache
result - value to add in the cache
cache - reference for EagerCaching in case the entry needs to remove itself from the cache.
Returns:
the query cache entry to add to the cache
See Also:
CacheBehavior.getCacheEntry(SelectRequest, ControllerResultSet, AbstractResultCache)

getXml

public java.lang.String getXml()
Description copied from class: CacheBehavior
Implementation specific xml dump of the cache behavior.

Specified by:
getXml in class CacheBehavior
Returns:
xml dump of the cache behavior
See Also:
XmlComponent.getXml()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.