473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 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 1489
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.