473,388 Members | 1,326 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,388 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 1751
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.