我希望缓存元素中的项目应该在特定时间每天下午11:59:59被删除一次。
我知道在缓存中有一个属性absoluteExpiration
,可以在一段时间内使用。
我使用下面的代码来设置缓存如何在特定时间每天删除缓存项目
public static Collection<CProductMakesProps> GetCachedSmartPhoneMake(HttpContext context)
{
var allMake = context.Cache["SmartPhoneMake"] as Collection<CProductMakesProps>;
if (allMake == null)
{
allMake = new CModelRestrictionLogic().GetTopMakes();
context.Cache.Insert("SmartPhoneMake", allMake, null,
DateTime.Now.AddHours(Int32.Parse(ConfigurationManager.AppSettings["MakeCacheTime"])),
Cache.NoSlidingExpiration);
}
return allMake;
}
值,但我怎么能设置的确切时间时,高速缓存应该过期。
我是否需要manipulate
时间变量并计算出time difference
并设置了absoluteExpiration
或者有其他方法。
计算时间差并设置absoluteexpiration – user2031802