com.github.houbbbbb.sso.scheduler.SchedulerRunner Maven / Gradle / Ivy
package com.github.houbbbbb.sso.scheduler;
import com.github.houbbbbb.sso.config.SSOFilterCNF;
import com.github.houbbbbb.sso.cons.SSOCON;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import java.util.concurrent.TimeUnit;
/**
* @author : hbw
* @desctiption :
* @date : 2020-06-23 14:09
*/
public class SchedulerRunner implements ApplicationRunner {
private SSOFilterCNF ssoFilterCNF;
public SchedulerRunner(SSOFilterCNF ssoFilterCNF){
this.ssoFilterCNF = ssoFilterCNF;
}
@Override
public void run(ApplicationArguments args) {
System.out.println("启动时执行 ---- 定时清除缓存");
Scheduler.INSTANCE.getExecutor().scheduleAtFixedRate(() -> SSOCON.removeUserCacheAll(), 0, ssoFilterCNF.getCacheTimeout(), TimeUnit.MINUTES);
}
}