好吧,每次用户点击我的网络服务时,我都会向缓存中添加一个项目:
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;
}