473,387 Members | 1,798 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,387 software developers and data experts.

Caching vs. public variables in vb.net 2003 web app

Can anybody clarify this please.
Is there any problem in a web app of saving an object in a public variable
as opposed to saving it in the cache?

In my case, I have an object containing a hash table of text labels and
their keys which I save in a public variable.

Any access to the object causes it to check if it has been initialised, and
if not it loads the hash table from the database, at which point it logs a
message to indicate the load has occurred. On examination of the log, I only
see it load once when the application starts, which is waht I want it to do.

The question is, am I going to have some problem doing it this way, and if
not, what benefit does the cache object have?

Thanks
Rick Gwadera
Software designer, programmer etc.

Jan 19 '06 #1
1 1452
EJD
Rick,
I'm going on a limb here and I won't claim to be an expert but I guess
one of the questions related to your question would be "how will your
public variable survive garbage collection?" If the variable is being
used repeatedly while the application is running, then it will tend to
survive, but I've also seen cached items get disposed of when I was not
expecting it. However, nearly everything can also be cached and there
are the persistence properties for the Caching class that can be set
for a cached item.

I once had a drop down list whose datasource was a DataSet that was
part of a user control that sat in every page in my application. And
although the dataset was cached there would be times when the page
would load and the drop down list would be empty. After putting some
code around the cached dataset code to check if it was not null, I was
able to fix the problem. I ended up doing something along these
lines...

DataSet dsDropDownList;
public DataSet DsDropDownList
{
get
{
if (dsDropDownList == null)
{
if (Cache["DsDropDownList"] == null)
{
dsDropDownList = GetDataSet();
}
else
{
dsDropDownList = (DataSet)Cache["DsDropDownList"];
}
}
if ((string)Context.Cache["UpdateDataSet"] == "true")
{
lock(this)
{
dsDropDownList = GetDataSet();
Cache["UpdateDataSet"] = "false";
}
}
return dsDropDownList;
}
}
I don't know if this will help but I think ultimately, time permitting,
you might want to try both ways of doing it to see which one suits you
best. HTH. Good luck!
Eric

Jan 20 '06 #2

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

Similar topics

0
by: Luca Calderano | last post by:
I MEAN YOU CAN ACCESS ADO TROUGHT COM AS EXPLAINED HERE: import win32com.client import locale from os import sys adCmdStoredProc = 4 # Evaluates CommandText as a stored procedure...
0
by: Martin | last post by:
Hi. I had a very frustrating afternoon and evening but I have got it all under control now so all of a sudden I am in a good mood. I want to share some insights on output caching with you lot. ...
0
by: Troy Simpson | last post by:
Hi, I have a website which is made up of dynamic pages. Each page that's loaded has some code which looks at which template to load amongst other things, which causes the page to take a little...
1
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open...
0
by: Rick Hein | last post by:
I've got a problem with an app I've been working on, the Caching object and events not firing correctly. In a nutshell: When I'm debugging, and I set a breakpoint in the removed item call back, the...
4
by: Nick Dreyer | last post by:
Is it possible to see public class variables of a COM addin in Excel 97 VBA? I have successfully created the (Visual Basic 2003 .NET) COM and referenced it in an Excel 97 VBA project. The VBA...
4
by: B | last post by:
Hi, I'm working on a site where the user must log in before they see the home page. When the user logs in, I retrieve their role from the database, store it in a Session object and redirect...
5
by: Henry Jones | last post by:
I posted in dotnet.general but I think this is a better place to post a VB question. I created a module in VS 2005 - Visual Basic Windows Project. I declared two strings public Public...
0
by: jason | last post by:
hi experts, support.microsoft.com/kb/917072 and http://msdn.microsoft.com/msdnmag/issues/06/07/WebAppFollies/ As pointed out in these articles, users might get session variables belong to...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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.