M
martin
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 expire in 5 minutes like so.
If Not IsPostBack Then
BindMyDropDown()
Else
Response.Write("<hr>Cache Expires 5 minutes" &
DateTime.Now.AddSeconds(300) & "<hr>")
'If the cache had expired I would expect this line to cause an
error -- but it doesn't even if I cause postback after 15 minutes!!!
dsMyDataset = CType(Cache("ds"), DataSet)
Response.Cache.SetExpires(DateTime.Now.AddSeconds(300))
End If
I also set the cache expire in exactly the same way in the BindMyDropDown()
function.
and place the dataset into the cache like so.
//code here
objConn.Open()
daMyDataAdapter.Fill(dsMyDataset, "Customers")
objConn.Close()
Cache.Insert("ds", dsMyDataset)
Response.Write("<hr>Cache Expires 5 minutes" &
DateTime.Now.AddSeconds(300) & "<hr>")
Response.Cache.SetExpires(DateTime.Now.AddSeconds(300))
DropDownList1.DataSource = dsMyDataset
DropDownList1.DataValueField =
dsMyDataset.Tables(0).Columns(0).ToString
DropDownList1.DataTextField =
dsMyDataset.Tables(0).Columns(1).ToString
DropDownList1.DataBind()
when a button is clicked and a postback is caused the button handler
retrieves the cache dataset and rebinds it to a combo box.
I would have thought that if the page was posted back any later than 5
minutes that an error would occur because the cache had expired, but it
doesn't.
The lack of this error indicates to me that the cache is not expiring, but I
do not know what I am doing wrong.
How do I make the cache expire in 5 minutes.
cheers
martin
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 expire in 5 minutes like so.
If Not IsPostBack Then
BindMyDropDown()
Else
Response.Write("<hr>Cache Expires 5 minutes" &
DateTime.Now.AddSeconds(300) & "<hr>")
'If the cache had expired I would expect this line to cause an
error -- but it doesn't even if I cause postback after 15 minutes!!!
dsMyDataset = CType(Cache("ds"), DataSet)
Response.Cache.SetExpires(DateTime.Now.AddSeconds(300))
End If
I also set the cache expire in exactly the same way in the BindMyDropDown()
function.
and place the dataset into the cache like so.
//code here
objConn.Open()
daMyDataAdapter.Fill(dsMyDataset, "Customers")
objConn.Close()
Cache.Insert("ds", dsMyDataset)
Response.Write("<hr>Cache Expires 5 minutes" &
DateTime.Now.AddSeconds(300) & "<hr>")
Response.Cache.SetExpires(DateTime.Now.AddSeconds(300))
DropDownList1.DataSource = dsMyDataset
DropDownList1.DataValueField =
dsMyDataset.Tables(0).Columns(0).ToString
DropDownList1.DataTextField =
dsMyDataset.Tables(0).Columns(1).ToString
DropDownList1.DataBind()
when a button is clicked and a postback is caused the button handler
retrieves the cache dataset and rebinds it to a combo box.
I would have thought that if the page was posted back any later than 5
minutes that an error would occur because the cache had expired, but it
doesn't.
The lack of this error indicates to me that the cache is not expiring, but I
do not know what I am doing wrong.
How do I make the cache expire in 5 minutes.
cheers
martin