001 package railo.runtime.query; 002 003 import java.io.Serializable; 004 import java.util.Date; 005 006 import railo.runtime.PageContext; 007 import railo.runtime.dump.DumpData; 008 import railo.runtime.dump.DumpProperties; 009 import railo.runtime.dump.DumpTable; 010 import railo.runtime.dump.DumpUtil; 011 import railo.runtime.dump.Dumpable; 012 import railo.runtime.dump.SimpleDumpData; 013 import railo.runtime.op.Duplicator; 014 import railo.runtime.type.dt.DateTimeImpl; 015 016 /** 017 * a single entry of the query cache 018 */ 019 public final class QueryCacheEntry implements Serializable,Dumpable { 020 021 private static final long serialVersionUID = -8991589914700895254L; 022 023 private Object value; 024 private long creationDate; 025 026 /** 027 * constructor of the class 028 * @param cacheBefore 029 * @param query 030 */ 031 QueryCacheEntry(Date cacheBefore, Object value) { 032 this.value = Duplicator.duplicate(value,false); 033 this.creationDate=System.currentTimeMillis(); 034 } 035 036 /** 037 * @param cacheAfter 038 * @return is in range or not 039 */ 040 public boolean isCachedAfter(Date cacheAfter) { 041 if(cacheAfter==null) return true; 042 if(creationDate>=cacheAfter.getTime()){ 043 return true; 044 } 045 return false; 046 } 047 048 /** 049 * @return returns query object in entry 050 */ 051 public Object getValue() { 052 this.creationDate=System.currentTimeMillis(); 053 return Duplicator.duplicate(value,false); 054 } 055 056 public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties properties) { 057 DumpTable table = new DumpTable("#669999","#ccffff","#000000"); 058 table.setTitle("QueryCacheEntry"); 059 table.appendRow(1,new SimpleDumpData("Value"),DumpUtil.toDumpData(value, pageContext, maxlevel, properties)); 060 table.appendRow(1,new SimpleDumpData("Creation Date"),DumpUtil.toDumpData(new DateTimeImpl(creationDate,false), pageContext, maxlevel, properties)); 061 return table; 062 } 063 }