Closed ikvm closed 5 years ago
改成下面就好了: ` namespace Aliyun.Acs.Core.Utils { public class CacheTimeHelper { private static ConcurrentDictionary<String, DateTime> lastClearTimePerProduct = new ConcurrentDictionary<string, DateTime>(); private const int ENDPOINT_CACHE_TIME = 3600; //Seconds
public static bool CheckCacheIsExpire(String product, String regionId)
{
DateTime lastClearTime;
String key = product + "_" + regionId;
if (lastClearTimePerProduct.ContainsKey(key))
{
lastClearTime = lastClearTimePerProduct[key];
}
else
{
lastClearTime = DateTime.Now;
lastClearTimePerProduct.TryAdd(key, lastClearTime);
}
TimeSpan ts = DateTime.Now - lastClearTime;
if (ENDPOINT_CACHE_TIME < ts.TotalSeconds)
{
return true;
}
return false;
}
public static void AddLastClearTimePerProduct(String product, String regionId, DateTime lastClearTime)
{
String key = product + "_" + regionId;
if (lastClearTimePerProduct.ContainsKey(key))
{
lastClearTimePerProduct.TryRemove(key,out DateTime dt);
}
lastClearTimePerProduct.TryAdd(key, lastClearTime);
}
}
} `
System.Collections.Generic.Dictionary`2[[System.Canon, mscorlib],[System.DateTime, mscorlib]].FindEntry(System.Canon) Aliyun.Acs.Core.Utils.CacheTimeHelper.AddLastClearTimePerProduct