1 28 29 package com.caucho.util; 30 31 51 public class TimedItem { 52 private long expireInterval; 53 54 private long createTime; 55 private Object value; 56 57 62 public TimedItem(long expireInterval) 63 { 64 this.expireInterval = expireInterval; 65 } 66 67 70 public long getExpireInterval() 71 { 72 return expireInterval; 73 } 74 75 78 public void setExpireInterval(long expireInterval) 79 { 80 this.expireInterval = expireInterval; 81 } 82 83 86 public void put(Object value) 87 { 88 createTime = Alarm.getCurrentTime(); 89 this.value = value; 90 } 91 92 95 public Object get() 96 { 97 if (Alarm.getCurrentTime() < createTime + expireInterval) 98 return value; 99 else { 100 Object v = value; 101 value = null; 102 103 if (v instanceof CacheListener) 104 ((CacheListener) v).removeEvent(); 105 106 return null; 107 } 108 } 109 } 110 111 112 | Popular Tags |