473,672 Members | 2,589 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cache reseting problem stumped

I have an asp.net project with a business layer (project) that has a class
called references. It loads up a data set and stores in cache with the
following code.

_cached = CType(HttpConte xt.Current.Cach e("cached"), String)
If HttpContext.Cur rent.Cache("cac hed") Is Nothing Or _cached <>
"loaded" Then
MyBase.CreateCo mmand("SA_GetRe ferences", _connectionStri ng)
_dsReferences = MyBase.ExecData Set
HttpContext.Cur rent.Cache.Inse rt("dsReference s", _dsReferences,
Nothing, DateTime.Now.Ad dMinutes(60), TimeSpan.Zero)
HttpContext.Cur rent.Cache.Inse rt("cached", "loaded", Nothing,
DateTime.Now.Ad dMinutes(60), TimeSpan.Zero)
End If
_dsReferences = CType(HttpConte xt.Current.Cach e("dsReferences "),
DataSet)

I have a number of properties that checks if in cache and if so returns the
appropriate datatable. If not then it loads up via above method..

Public ReadOnly Property dtLegalEntities () As DataTable
Get
LoadDs()
Return _dsReferences.T ables(9)
End Get
End Property
I also have a shared method to set cache to 'clear' in the few cases when i
want to clear it out.

Public Shared Sub ClearCache()
HttpContext.Cur rent.Cache("cac hed") = "clear"
End Sub

The problem is that for some reason the app error's out complaining that
datatables are not in cache. I dont know how that is possible as with each
reference to the datatable it does the above check. I have made sure that
none of the cached tables are set to nothing.

any ideas on why this is happening? (i have used this technique in other
apps and have not seen this as a problem before).

thx
dave

Apr 13 '07 #1
1 1396
KJ
I suggest you use the overloaded version of Cache.Insert, and specify
a CacheItemPriori ty of AboveNormal. Otherwise, it will be dumped from
the Cache asap. To see if this is what's happening, provide a
CacheItemRemove dCallback delegate parameter as well to Insert.

On Apr 13, 4:02 pm, dave <d...@discussio ns.microsoft.co mwrote:
I have an asp.net project with a business layer (project) that has a class
called references. It loads up a data set and stores in cache with the
following code.

_cached = CType(HttpConte xt.Current.Cach e("cached"), String)
If HttpContext.Cur rent.Cache("cac hed") Is Nothing Or _cached <>
"loaded" Then
MyBase.CreateCo mmand("SA_GetRe ferences", _connectionStri ng)
_dsReferences = MyBase.ExecData Set
HttpContext.Cur rent.Cache.Inse rt("dsReference s", _dsReferences,
Nothing, DateTime.Now.Ad dMinutes(60), TimeSpan.Zero)
HttpContext.Cur rent.Cache.Inse rt("cached", "loaded", Nothing,
DateTime.Now.Ad dMinutes(60), TimeSpan.Zero)
End If
_dsReferences = CType(HttpConte xt.Current.Cach e("dsReferences "),
DataSet)

I have a number of properties that checks if in cache and if so returns the
appropriate datatable. If not then it loads up via above method..

Public ReadOnly Property dtLegalEntities () As DataTable
Get
LoadDs()
Return _dsReferences.T ables(9)
End Get
End Property

I also have a shared method to set cache to 'clear' in the few cases when i
want to clear it out.

Public Shared Sub ClearCache()
HttpContext.Cur rent.Cache("cac hed") = "clear"
End Sub

The problem is that for some reason the app error's out complaining that
datatables are not in cache. I dont know how that is possible as with each
reference to the datatable it does the above check. I have made sure that
none of the cached tables are set to nothing.

any ideas on why this is happening? (i have used this technique in other
apps and have not seen this as a problem before).

thx
dave

Apr 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1539
by: waschbaer2 | last post by:
Hi! What's the proper Visual Basic for Applications (VBA) code for reseting the menu bar and the tool bar in Access. Thanks in advance, Markus
3
2846
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
2073
by: martin | last post by:
Hi, I have a page that contain a dropdown list of values. This drop down list rarely changes so I wish to cache the page. However the values in the dropdown box are taken from a database, so if the values in the database change I wish to expire the cache and go to the database again and get a fresh copy. I have worked out that I should use one of the methods of cache.insert that take a cache dependency object, for example
1
1087
by: Dave | last post by:
I have a page with a button that updates a table in the database. This should affect the data displayed on the page. I've used break points to ensure that the code calling the query to collect the data is being properly called. The query process itself consists of building a new SqlConnection object from the connection string. Creating a new SqlCommand, setting the command text and type to the stored procedure, setting the parameters....
14
2088
by: Tom.PesterDELETETHISSS | last post by:
Hi, I think this question requires an in depth understanding of how a browser cache works. I hope I can reach an expert here. I may have found a quirk in the asp.net documentation or I don't understand what the SetAllowResponseInBrowserHistory does. While researching caching I tried the code sample at the following page : http://msdn2.microsoft.com/library/97wcd0a4(en-us,vs.80).aspx
0
884
by: bthomas71chevy | last post by:
(I hope I can explain this correctly and someone can clarify it and or correct me if I'm wrong?) After a Build of a Web App and deployment, each pages server cache is dropped and that is why the first time to each page the page is rendered it is slow because of the page being recached. If the Project is not rebuilt and redeployed, but the page is having to rerender as the Server Cache is gone, where is that setting being set to tell...
0
2300
by: mateipuiu | last post by:
When a try to run a client build on 2005, which uses the Microsoft.ApplicationBlocks.Cache.dll reference, when using a Microsoft.ApplicationBlocks.Cache.dll created on Debug mode, the client works just fine, but when a use a Microsoft.ApplicationBlocks.Cache.dll created on Release mode, the client doesn't work no more, and I get this error message: ********************************************* 1) Exception Information...
5
2110
by: Stan SR | last post by:
Hi, Some newbie questions.. :-) First, what is the namespace to use for the Cache class ? When I use this bit of code I get an error if (Cache==null) Cache.Insert("myUserList",userlist); I don't know which namespace to use.
3
2364
by: Henry | last post by:
I have a simple form on a page in my website in which a user can enter an email address to be added to a mailing list. The following ASP script works the first time a user submits his or her email address. However, if the same user tries to submit another email, the browser hangs and times out. If the user clears the browser's cache, this script works fine. Could someone please explain this behaviour and how I can resolve it? Thanks!
0
8504
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8945
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
8697
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7476
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6255
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
5720
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
4439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2840
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
2
1839
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.