I have a cache object in C# that still has not expired yet, and I want to update the value of its key. How do I do that? This is for an ASP.NET MVC web app. For example:
UserLogin userLogin = new UserLogin() {
LoginAttempts = 1,
DateTimeAttempted = DateTime.Now
};
if (System.Web.HttpContext.Current.Cache["LoginInfo"] == null)
{
System.Web.HttpContext.Current.Cache.Insert("LoginInfo", userLogin, null, DateTime.Now.AddSeconds(60), TimeSpan.Zero);
}
if (System.Web.HttpContext.Current.Cache["LoginInfo"] != null && UserAuthenticationFailedAgain)
{
userLogin.LoginAttempts = 2;
userLogin.DateTimeAttempted = DateTime.Now;
// Now how do I update the value of this existing cache object's key "LoginInfo" so that the when I access Cache["LoginInfo"].LoginAttempts and Cache["LoginInfo"]. DateTimeAttempted, I get 2 and an updated date time, respectively?? I don't see System.Web.HttpContext.Current.Cache.Update() in docs.microsoft.com
}
Many thanks in advance.