All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy