467,867 Members | 1,316 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,867 developers. It's quick & easy.

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
  • viewed: 1626
Share:
2 Replies
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Brian Vallelunga | last post: by
3 posts views Thread by martin | last post: by
1 post views Thread by Tony Hsieh | last post: by
1 post views Thread by Bogdan Fiedur | last post: by
3 posts views Thread by Jon | last post: by
4 posts views Thread by =?Utf-8?B?YmxhY2toYXdr?= | last post: by
5 posts views Thread by =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.