1 18 19 package org.apache.roller.util.cache; 20 21 import java.io.Serializable ; 22 23 24 30 public class ExpiringCacheEntry implements Serializable { 31 32 private Object value; 33 private long timeCached = -1; 34 private long timeout = 0; 35 36 37 public ExpiringCacheEntry(Object value, long timeout) { 38 this.value = value; 39 40 if(timeout > 0) { 42 this.timeout = timeout; 43 } 44 45 this.timeCached = System.currentTimeMillis(); 46 } 47 48 49 public long getTimeCached() { 50 return this.timeCached; 51 } 52 53 54 public long getTimeout() { 55 return this.timeout; 56 } 57 58 59 64 public Object getValue() { 65 if(this.hasExpired()) { 66 return null; 67 } else { 68 return this.value; 69 } 70 } 71 72 73 76 public boolean hasExpired() { 77 78 long now = System.currentTimeMillis(); 79 80 return ((this.timeCached + this.timeout) < now); 81 } 82 83 } 84 | Popular Tags |