The examples for Cache.Add uses DateTime.Now.Add
to compute the expiration, i.e. it passes:
DateTime.Now.AddSeconds(60)
as th
Cache.Add
converts the expiration date to UTC before storing it.
From Reflector (I've omitted most of the parameters to make it easier to read):
public object Add(... DateTime absoluteExpiration ...)
{
DateTime utcAbsoluteExpiration = DateTimeUtil.ConvertToUniversalTime(absoluteExpiration);
return this._cacheInternal.DoInsert(... utcAbsoluteExpiration ...);
}
In CacheExpires.FlushExpiredItems
, utcAbsoluteExpiration
is compared to DateTime.UtcNow
. As Joe notes in his answer, this causes unexpected behavior when a cache item's addition and expiration span the end of daylight saving time.