parent
db8615d81e
commit
90c8a1cd06
@ -1,45 +0,0 @@
|
||||
package xyz.wbsite.config;
|
||||
|
||||
import net.sf.ehcache.Cache;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import net.sf.ehcache.config.CacheConfiguration;
|
||||
import net.sf.ehcache.config.DiskStoreConfiguration;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.ehcache.EhCacheCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class CacheConfig {
|
||||
|
||||
public static final String TOKEN_CACHE = "tokenCache";
|
||||
|
||||
@Bean
|
||||
public EhCacheCacheManager getCacheManager() {
|
||||
net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();
|
||||
// todo 需根据服务器物理内存配置
|
||||
configuration.setMaxBytesLocalHeap("128M");
|
||||
configuration.updateCheck(false);
|
||||
configuration.addDiskStore(new DiskStoreConfiguration().path("java.io.tmpdir"));
|
||||
CacheManager cacheManager = CacheManager.create(configuration);
|
||||
|
||||
// 添加token缓存
|
||||
cacheManager.addCache(buildTokenCache());
|
||||
return new EhCacheCacheManager(cacheManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建TokenCache
|
||||
*
|
||||
* @return 缓存
|
||||
*/
|
||||
private Cache buildTokenCache() {
|
||||
CacheConfiguration config = new CacheConfiguration();
|
||||
config.setMemoryStoreEvictionPolicy("LFU");//最少使用
|
||||
config.setTimeToLiveSeconds(60 * 60);//最长有效时间
|
||||
config.setTimeToIdleSeconds(60 * 60);//无访问最长有效时间
|
||||
config.setName(TOKEN_CACHE);
|
||||
return new Cache(config);
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package xyz.wbsite.task;
|
||||
|
||||
import xyz.wbsite.frame.schedule.RunDelayRepeatTask;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class TokenTask extends RunDelayRepeatTask {
|
||||
|
||||
@Override
|
||||
public String taskId() {
|
||||
return "task1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration interval() {
|
||||
return Duration.ofMinutes(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// TokensManager tokensManager = LocalData.getBean(TokensManager.class);
|
||||
// if (tokensManager == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// TokensFindRequest tokensFindRequest = new TokensFindRequest();
|
||||
// tokensFindRequest.setPageSize(0);
|
||||
// tokensFindRequest.setValid(true);
|
||||
// TokensFindResponse tokensFindResponse = tokensManager.find(tokensFindRequest, LocalData.getSysToken());
|
||||
//
|
||||
// Date current = new Date();
|
||||
// for (Tokens tokens : tokensFindResponse.getResult()) {
|
||||
// if (tokens.getValidTime().before(current)) {
|
||||
// TokensLogoutRequest tokensLogoutRequest = new TokensLogoutRequest();
|
||||
// tokensLogoutRequest.setToken(tokens.getToken());
|
||||
// TokensLogoutResponse tokensLogoutResponse = tokensManager.logout(tokensLogoutRequest, LocalData.getSysToken());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
@echo off
|
||||
cd %cd%
|
||||
start java -Dfile.encoding=UTF-8 -jar nginx-admin-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
|
@ -1,3 +0,0 @@
|
||||
@echo off
|
||||
cd %cd%
|
||||
start java -Dfile.encoding=UTF-8 -jar nginx-admin-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod
|
@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
cd %cd%
|
||||
start java -Xmx256M -Dfile.encoding=UTF-8 -jar nginx-admin-0.0.1-SNAPSHOT.jar
|
Loading…
Reference in new issue