G
Guest
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
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