T
Tony Hsieh
Hi,
So I have a asp page that displays the results of a database query
that takes 3 minutes to run. I want to cache this dataset for 10
hours so I don't have to perform the 3 minute query every time someone
goes to the page. The code I use is:
if (Cache[TableCacheName] == null) {
mainConnection = new
SqlConnection(@"SERVER=X;DATABASE=Y;Trusted_Connection=Yes");
SqlDataAdapter mainDA = new
SqlDataAdapter(weeklyQuery, mainConnection);
DataSet daWeekly = new DataSet();
mainDA.SelectCommand.CommandTimeout = 900;
mainDA.Fill(daWeekly, "Weekly");
//i want the cache to expire in 10 hours
Cache.Insert(TableCacheName,
daWeekly.Tables["Weekly"],null,DateTime.Now.AddHours(10),
Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
}
The problem I've been having is that the dataset is not staying in my
cache for more than an hour even though I have expliciting set its
absolute expiration time to be 10 hours from now. My server also has
plently of memory. I don't know whats going wrong. Is there some
setting in IIS thats killing the cache? This has been extremely
frustrating and any help would be greatly appreciated. Thanks so
much.
-Tony
So I have a asp page that displays the results of a database query
that takes 3 minutes to run. I want to cache this dataset for 10
hours so I don't have to perform the 3 minute query every time someone
goes to the page. The code I use is:
if (Cache[TableCacheName] == null) {
mainConnection = new
SqlConnection(@"SERVER=X;DATABASE=Y;Trusted_Connection=Yes");
SqlDataAdapter mainDA = new
SqlDataAdapter(weeklyQuery, mainConnection);
DataSet daWeekly = new DataSet();
mainDA.SelectCommand.CommandTimeout = 900;
mainDA.Fill(daWeekly, "Weekly");
//i want the cache to expire in 10 hours
Cache.Insert(TableCacheName,
daWeekly.Tables["Weekly"],null,DateTime.Now.AddHours(10),
Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
}
The problem I've been having is that the dataset is not staying in my
cache for more than an hour even though I have expliciting set its
absolute expiration time to be 10 hours from now. My server also has
plently of memory. I don't know whats going wrong. Is there some
setting in IIS thats killing the cache? This has been extremely
frustrating and any help would be greatly appreciated. Thanks so
much.
-Tony