1 24 25 package org.objectweb.cjdbc.controller.cache.result.rules; 26 27 import org.objectweb.cjdbc.common.sql.SelectRequest; 28 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags; 29 import org.objectweb.cjdbc.controller.cache.result.AbstractResultCache; 30 import org.objectweb.cjdbc.controller.cache.result.CacheBehavior; 31 import org.objectweb.cjdbc.controller.cache.result.entries.AbstractResultCacheEntry; 32 import org.objectweb.cjdbc.controller.cache.result.entries.ResultCacheEntryRelaxed; 33 import org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet; 34 35 50 public class RelaxedCaching extends CacheBehavior 51 { 52 private long timeout; 53 private boolean keepIfNotDirty; 54 55 61 public RelaxedCaching(boolean keepIfNotDirty, long timeout) 62 { 63 this.keepIfNotDirty = keepIfNotDirty; 64 this.timeout = timeout; 65 } 66 67 71 public AbstractResultCacheEntry getCacheEntry(SelectRequest sqlQuery, 72 ControllerResultSet result, AbstractResultCache cache) 73 { 74 return new ResultCacheEntryRelaxed(sqlQuery, result, timeout, 75 keepIfNotDirty); 76 } 77 78 81 public String getXml() 82 { 83 return "<" + DatabasesXmlTags.ELT_RelaxedCaching + " " 84 + DatabasesXmlTags.ATT_timeout + "=\"" + timeout / 1000 + "\" " 85 + DatabasesXmlTags.ATT_keepIfNotDirty + "=\"" + keepIfNotDirty + "\"/>"; 86 } 87 88 } | Popular Tags |