472,791 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

cache expiring prematurely

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_Connec tion=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
Nov 18 '05 #1
1 1438
It very well could be. IIS could be closing out the application, which it
normally does after the last session closes. Then the ASP.Net garbage
collection will kick in and clean up unused items. You could try upping the
session timeout to something ridiculously high as the application won't
expire until the last session has been destroyed, and a typical session
lasts about 20 minutes.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Tony Hsieh" <bo*****@yahoo.com> wrote in message
news:55*************************@posting.google.co m...
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_Connec tion=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

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brian Vallelunga | last post by:
I'm having a problem using the Cache object with asp.net. Here is what I have: 1) I put something in cache and set its callback method. 2) The object times out after X minutes and calls the...
3
by: martin | last post by:
Hi, I am storing a dataset in cache, which is happening fine. I can easily retrive it at postback from the cache, cast it to a dataset and reuse it. However I have specified that the cache...
1
by: Bogdan Fiedur | last post by:
Hi All, Recently our production server asp.net cache expires on average every 5 seconds. Any clues why is this happening and how to fix it. Bogdan Fiedur
3
by: Jon | last post by:
I have a couple of tables I want to load into a dataset and keep around pretty much forever, although they will need to be refreshed every so often. I can either put the dataset into an...
4
by: Beren | last post by:
Hello I'm trying to use Cache expiration and its callback feature to easily add automated tasks programmatically. The task should be run when the Cache object expired The problem I'm facing...
6
by: Adam | last post by:
On an xp machine, the caching works as expected. I have deployed to a win2k server, and an item I add to the cache expires almost immediately some times and in under a minute in other times. The...
1
by: Sashko | last post by:
Hi, I made an ASP.NET (.NET 1.1) application that uses the Context.Cache object within Global.asax as a static member. It is set up in such a way that whenever the cache items expire, they...
2
by: Don | last post by:
I've come across a weird behaviour with regards to the cache object. I couldn't find any documentation which could explain this. Basically the problem has to do with the cache item NOT expiring....
5
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post by:
I have a site which I secure with forms authentication. When the user's sign on and hit one of the secure pages, I have this line in my code to ensure that the browser does not cache the page;...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.