Hi, I want to perform caching of data for 1 day. In my MVC model I am getting the data from the database and the using it on my View. I want to add the data in cache if not there.If it is already in cache then getting the result directly form there. In my model I have a function result() in that I have used caching as
if (HttpContext.Current.Cache[ID] == null)
{
query = db.Employee.FirstOrDefault(x=>x.id.Equals(ID));
HttpContext.Current.Cache.Insert
(ID, query, null,DateTime.Now.AddDays(1),
System.Web.Caching.Cache.NoSlidingExpiration);
} else query = (Employee)HttpContext.Current.Cache[ID];
But here caching works only for current request and after that again data is retrived from database and a new insertion is performed in cache for the same data. I want the data in cache for 1 day. Please provide me the way to cache my data.
Thanks.