com.infomaximum.cluster.utils.ExpireObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cluster Show documentation
Show all versions of cluster Show documentation
Library for creating a light cluster
package com.infomaximum.cluster.utils;
import java.time.Duration;
public class ExpireObject {
private final T object;
private long timeUpdate;
public ExpireObject(T object) {
this.object = object;
this.timeUpdate = System.currentTimeMillis();
}
public T get() {
this.timeUpdate = System.currentTimeMillis();
return object;
}
public boolean isExpire(Duration expire) {
return ((System.currentTimeMillis() - timeUpdate) > expire.toMillis());
}
}