com.neko233.toolchain.common.cache.objects.ref.TimestampSoftRef Maven / Gradle / Ivy
package com.neko233.toolchain.common.cache.objects.ref;
import java.lang.ref.SoftReference;
/**
* @author SolarisNeko on 2022-12-12
**/
public class TimestampSoftRef extends SoftReference {
private volatile long visitMs;
public TimestampSoftRef(V data) {
super(data);
this.visitMs = System.currentTimeMillis();
}
public long getVisitMs() {
return visitMs;
}
private TimestampSoftRef refreshTime() {
visitMs = System.currentTimeMillis();
return this;
}
@Override
public V get() {
refreshTime();
return super.get();
}
}