2018-05-18 17:50:51 +02:00
|
|
|
package org.gcube.spatial.data.sdi.engine.impl.is;
|
2017-04-11 18:07:58 +02:00
|
|
|
|
|
|
|
public class CachedObject<T> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private long lastUpdate=System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
|
|
private T theObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CachedObject(T theObject) {
|
|
|
|
super();
|
|
|
|
this.theObject = theObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
public T getTheObject() {
|
|
|
|
return theObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isValid(long TTL){
|
|
|
|
return System.currentTimeMillis()-lastUpdate<TTL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void invalidate(){
|
|
|
|
lastUpdate=0l;
|
|
|
|
}
|
|
|
|
}
|