473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Cache

I am currently having a problem with retaining the cache in my asp.net
application. I am trying to insert a small DataView into cache, then
recall it on various pages throughout the site. When on any page other
than the page that inserted the cache, the DataView is null (not the
cache object, but the DataView itself). I'm curious as to if my code
is wrong, or if the DataView wasn't meant to be placed into cache.

// Code for insert
System.Web.HttpContext.Current.Cache.Insert(
"key",
dataView,
null,
DateTime.Now.AddHours(1),
TimeSpan.Zero
);

// Code for recall
DataView dv = (DataView)System.Web.HttpContext.Current.Cache[key];

Am I doing anything wrong? Might there be an entry that I would need
to add to my web.config to enable the cache? And on a side note, is
there a limit to the amount of characters placed in the key string?

Thank you,
Dave
Jul 19 '05 #1
3 4289
da**@digitallint.com (Dave) wrote in
news:f3**************************@posting.google.c om:
I am currently having a problem with retaining the cache in my
asp.net application. I am trying to insert a small DataView into
cache, then recall it on various pages throughout the site. When
on any page other than the page that inserted the cache, the
DataView is null (not the cache object, but the DataView
itself). I'm curious as to if my code is wrong, or if the
DataView wasn't meant to be placed into cache.

// Code for insert
System.Web.HttpContext.Current.Cache.Insert(
"key",
dataView,
null,
DateTime.Now.AddHours(1),
TimeSpan.Zero
);

// Code for recall
DataView dv =
(DataView)System.Web.HttpContext.Current.Cache[key];

Am I doing anything wrong? Might there be an entry that I would
need to add to my web.config to enable the cache? And on a side
note, is there a limit to the amount of characters placed in the
key string?


Dave,

It looks OK. Just make sure you are using the same key value. In
your Insert code you are using a "key" string literal. When
retrieving the value your code uses a string variable named key. If
the variable key does not contain the value "key" when trying to
recall the DataView, null will be returned.

Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Jul 19 '05 #2
> Dave,

It looks OK. Just make sure you are using the same key value. In
your Insert code you are using a "key" string literal. When
retrieving the value your code uses a string variable named key. If
the variable key does not contain the value "key" when trying to
recall the DataView, null will be returned.

Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

Cris,

Thank you for your response. I am using the proper keys for setting
and retrieving of the cached data. For my code example I just replaced
my variable with the string "key". There isn't any web.config or
special server settings to enable the cache, right?

Thanks,
Dave
Jul 19 '05 #3
I figured out my problem. =) I have a habbit of disposing of my
dataviews after I "no longer need them". In this case I was disposing
of it after using it in my control. This now brings up the question of
proper clean up.

Will .Net's garbage collection properly release the memory consumed by
the dataview when the cache expires?

Thanks,
Dave
da**@digitallint.com (Dave) wrote in message news:<f3**************************@posting.google. com>...
I am currently having a problem with retaining the cache in my asp.net
application. I am trying to insert a small DataView into cache, then
recall it on various pages throughout the site. When on any page other
than the page that inserted the cache, the DataView is null (not the
cache object, but the DataView itself). I'm curious as to if my code
is wrong, or if the DataView wasn't meant to be placed into cache.

// Code for insert
System.Web.HttpContext.Current.Cache.Insert(
"key",
dataView,
null,
DateTime.Now.AddHours(1),
TimeSpan.Zero
);

// Code for recall
DataView dv = (DataView)System.Web.HttpContext.Current.Cache[key];

Am I doing anything wrong? Might there be an entry that I would need
to add to my web.config to enable the cache? And on a side note, is
there a limit to the amount of characters placed in the key string?

Thank you,
Dave

Jul 19 '05 #4

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

Similar topics

3
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...
5
by: Darrel | last post by:
I thought this warranted a new thread. Yesterday I asked about access relatively static content...is it better to read from the DB, or just grab a text file. It was suggested that I use the DB...
14
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...
1
by: William Sullivan | last post by:
I'm trying to nail down some issues with the cache in my application. Currently, I have an object that stands between my business logic and database logic called CacheLogic (cute, no?). ...
13
by: Andrew Morton | last post by:
I am caching some data in VB.NET using System.Web.Caching, is it possible to lock the cache so that other sessions attempting to access the same cache wait when it is being updated? I have the...
26
by: Ed L. | last post by:
Here's some of my current notions on pgsql performance tuning strictly as it relates to pgsql tuning parameters in the context of a dedicated linux or hpux server. I'm particularly focusing on...
18
by: siddharthkhare | last post by:
Hi All, what is the diference between these two cache control header. no-cache and no-store. I have read the w3.org explanation. So lets say I am using only no-cache ....my understanding is...
0
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...
5
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);...
0
by: =?Utf-8?B?YmlqYXk=?= | last post by:
The type initializer for 'Microsoft.ApplicationBlocks.Cache.CacheService' threw an exception. We migrated our windows application from 1.1 to 2.0. The debug and Release mode of the application...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.