com.aliyuncs.utils.CacheTimeHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aliyun-java-sdk-core Show documentation
Show all versions of aliyun-java-sdk-core Show documentation
Aliyun Open API SDK for Java
Copyright (C) Alibaba Cloud Computing
All rights reserved.
版权所有 (C)阿里云计算有限公司
http://www.aliyun.com
package com.aliyuncs.utils;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class CacheTimeHelper {
private static long endPointCacheTime = 3600L; //Seconds
private static Map lastClearTimeMap = new HashMap();
public static boolean CheckEndPointCacheIsExpire(String product, String regionId)
{
String key = product + "_" + regionId;
Date lastClearTime;
if (null != lastClearTimeMap.get(key)) {
lastClearTime = lastClearTimeMap.get(key);
} else {
lastClearTime = new Date();
lastClearTimeMap.put(key, lastClearTime);
}
Date currentTime = new Date();
long elapsedTime = (currentTime.getTime() - lastClearTime.getTime())/1000L;
if (endPointCacheTime < elapsedTime)
{
return true;
}
return false;
}
public static void addLastClearTimePerProduct(String product, String regionId, Date date) {
String key = product + "_" + regionId;
lastClearTimeMap.put(key, date);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy