472,993 Members | 3,166 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,993 software developers and data experts.

Cache not expiring!

Don
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.
If you look at the below code, u'll see that i'm creating 2 cache items with
the keys ONE and TWO.
And both are set to expire in 30 seconds.

When i click the button every time before 30 seconds, i can view the cache
data.
How ever after 30 seconds elapse or after 2 hours, ONLY cache item TWO has
expired.
As for the first item (Key = ONE), it still EXISTS!!!

Is this a bug or have i missed out something?

Code:-

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Cache.Insert("ONE", "Item One", Nothing, Date.Now.AddSeconds(3), Nothing)
Cache("ONE") = "Item One-1"
Cache.Insert("TWO", "Item Two", Nothing, Date.Now.AddSeconds(3), Nothing)
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If Cache("ONE") Is Nothing Then
TextBox1.Text = "No cache item"
Else
TextBox1.Text = Cache("ONE")
End If

If Cache("TWO") Is Nothing Then
TextBox2.Text = "No cache item"
Else
TextBox2.Text = Cache("TWO")
End If
End Sub

Aug 3 '06 #1
2 1737
Don
The above query relates to ASP.NET 1.1

"Don" wrote:
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.
If you look at the below code, u'll see that i'm creating 2 cache items with
the keys ONE and TWO.
And both are set to expire in 30 seconds.

When i click the button every time before 30 seconds, i can view the cache
data.
How ever after 30 seconds elapse or after 2 hours, ONLY cache item TWO has
expired.
As for the first item (Key = ONE), it still EXISTS!!!

Is this a bug or have i missed out something?

Code:-

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Cache.Insert("ONE", "Item One", Nothing, Date.Now.AddSeconds(3), Nothing)
Cache("ONE") = "Item One-1"
Cache.Insert("TWO", "Item Two", Nothing, Date.Now.AddSeconds(3), Nothing)
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If Cache("ONE") Is Nothing Then
TextBox1.Text = "No cache item"
Else
TextBox1.Text = Cache("ONE")
End If

If Cache("TWO") Is Nothing Then
TextBox2.Text = "No cache item"
Else
TextBox2.Text = Cache("TWO")
End If
End Sub
Aug 3 '06 #2
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.
If you look at the below code, u'll see that i'm creating 2 cache items with
the keys ONE and TWO.
And both are set to expire in 30 seconds.

When i click the button every time before 30 seconds, i can view the cache
data.
How ever after 30 seconds elapse or after 2 hours, ONLY cache item TWO has
expired.
As for the first item (Key = ONE), it still EXISTS!!!

Is this a bug or have i missed out something?

Code:-

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Cache.Insert("ONE", "Item One", Nothing, Date.Now.AddSeconds(3), Nothing)
Cache("ONE") = "Item One-1"

Cache.Insert("TWO", "Item Two", Nothing, Date.Now.AddSeconds(3), Nothing)
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If Cache("ONE") Is Nothing Then
TextBox1.Text = "No cache item"
Else
TextBox1.Text = Cache("ONE")
End If

If Cache("TWO") Is Nothing Then
TextBox2.Text = "No cache item"
Else
TextBox2.Text = Cache("TWO")
End If
End Sub
My guess is that when you do
Cache("ONE") = "Item One-1"
you are replacing the previously "inserted" cache-item with one without
restrictions, instead of changing the stored value but keeping the
expiry-settings.

Hans Kesting
Aug 3 '06 #3

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: Tony Hsieh | last post by:
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...
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...
4
by: =?Utf-8?B?YmxhY2toYXdr?= | last post by:
I have a web service that I am putting together that queries a database and some of the queries take a fair bit of time. I want to cache the data, which I can easily do using the Application...
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.