1

好吧,每次用户点击我的网络服务时,我都会向缓存中添加一个项目:

DateTime? token = HttpContext.Current.Get(TimeoutKey) as DateTime?;

int hashkey = (email + password).GetHashCode();

if (token == null)
{
    HttpContext.Current.Cache.Add(
         hashkey.ToString(),
         DateTime.Now,
         null,
         Cache.NoAbsoluteExpiration,
         new TimeSpan(0, 20, 0),
         CacheItemPriority.NotRemoveable,
         UserTimedOut);
}
else
{
    // How to do this without triggering UserTimedOut?
    Cache[hashkey.ToString()] = DateTime.Now;
}
4

1 回答 1

0

你可以围绕DateTime可变的创建一个自定义类包装器,比如 aUserStateInfo吗?

于 2012-06-01T22:08:18.440 回答