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

top.zeimao77.product.converter.AbstractIntervalRefreshConverter Maven / Gradle / Ivy

package top.zeimao77.product.converter;

import java.time.LocalDateTime;

/**
 * @author zeimao77
 * 本次取数据时间与上次刷新时间相差cacheTime秒,触发刷新操作
 */
public abstract class AbstractIntervalRefreshConverter extends AbstractCustomRefreshConverter{

    /**
     * 时间间隔 刷新后会将过期时间设置为当前时间加上该时间 单位:秒
     */
    protected long cacheTime;

    /**
     * @param cacheTime 缓存时间 单位秒
     */
    public AbstractIntervalRefreshConverter(long cacheTime) {
        this.cacheTime = cacheTime;
    }

    /**
     * 默认缓存时间3600秒
     */
    public AbstractIntervalRefreshConverter(){
        this(0x0E10);
    }

    @Override
    protected void refreshExpiryTime() {
        setExpiryTime(LocalDateTime.now().plusSeconds(this.cacheTime));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy