473,941 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
Cache.Insert("O NE", "Item One", Nothing, Date.Now.AddSec onds(3), Nothing)
Cache("ONE") = "Item One-1"
Cache.Insert("T WO", "Item Two", Nothing, Date.Now.AddSec onds(3), Nothing)
End If
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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 1773
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.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
Cache.Insert("O NE", "Item One", Nothing, Date.Now.AddSec onds(3), Nothing)
Cache("ONE") = "Item One-1"
Cache.Insert("T WO", "Item Two", Nothing, Date.Now.AddSec onds(3), Nothing)
End If
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
Cache.Insert("O NE", "Item One", Nothing, Date.Now.AddSec onds(3), Nothing)
Cache("ONE") = "Item One-1"

Cache.Insert("T WO", "Item Two", Nothing, Date.Now.AddSec onds(3), Nothing)
End If
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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
2936
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 callback method specified. 3) The callback method gets the newest version of the item from the db and then calls a helper method to put the item back into cache. It looks like this: //Pseudocode
3
2868
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 expire in 5 minutes like so. If Not IsPostBack Then BindMyDropDown() Else Response.Write("<hr>Cache Expires 5 minutes" &
1
1516
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 time someone goes to the page. The code I use is: if (Cache == null) { mainConnection = new SqlConnection(@"SERVER=X;DATABASE=Y;Trusted_Connection=Yes");
1
1310
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
1558
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 Application("myDataset") var or I can put it into the cache, Cache("myDataset"), both are universally available to my app, except in Global.asax, only Application() vars are available (or it seems that way on my machine, at least). I thought it would be...
4
1452
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 is that some tasks will only be expiring (thus running) in 2 months. What if the server needs to reboot? Will the Cache be lost (and with it all my Tasks) ?
6
1784
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 aspnet_wp process is not restarting during this time, and there are no other requests, so nothing should be clearing this out. I have added a CacheItemRemovedCallback which writes debug info out to a DefaultTraceListener, but no output shows up on...
4
2288
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 object, but I want it to refresh itself periodically. The trick is, that I DON'T want the evaluation of the cach object expiring done at the time the client makes the query and then upon discovery that the cache has expired, it refreshes the data. ...
5
6812
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; and someone cannot navigate back to an cached image of the page in theory after the user has signed off. Response.Cache.SetCacheability(HttpCacheability.NoCache); This works all right, except when the user decides to use the browser's back...
0
9964
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11112
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
8218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6298
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.