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

Application Variables / Database Caching - Best Practice

Good morning,

I have a classic ASP app that I'm converting to .NET. In the existing app
when accessing infrequntly changed data, it reads a database once a day, and
saves the results in an application variable.

I'm trying to replicate this in .NET, but I'm using a data access layer
(DAL) that's in a seperate project. Obviously, the DAL can't see the
application variables. I was thinking of passing the application state in
the constructor, but this seems like overkill.

Can someone please point me in the direction of a "best practices" guide to
converting legacy application variable caching where an external DAL is
involved, or does anyone have any strong opinions on thie best way to do
this?

Regards,

Duncan
Nov 16 '05 #1
2 2695
If the ASP app was saving data in an application variable, then "once a day"
was optimistic... the application variable would time out and be destroyed
if the last user stopped using the app and no one else came in for 20
minutes. If your app is on the open internet and is reasonably popular,
then the app would remain in memory for a full 24 hours. However, an app
that is primarily used between 8 and 5 would probably time out its
application variables until the first user visits the next day.

So keeping that in mind:

I would implement a cache object using a singleton in the application. The
singleton pattern creates an object and stores it in a static variable. You
can find quite a few references on the web on creating singletons well in
C#.

This would behave similarly to the use of the app variable from your ASP
app.

Hope this helps,
--- Nick

"Duncan Welch" <du**@ntpcl.f9.co.uk> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl...
Good morning,

I have a classic ASP app that I'm converting to .NET. In the existing app
when accessing infrequntly changed data, it reads a database once a day, and saves the results in an application variable.

I'm trying to replicate this in .NET, but I'm using a data access layer
(DAL) that's in a seperate project. Obviously, the DAL can't see the
application variables. I was thinking of passing the application state in
the constructor, but this seems like overkill.

Can someone please point me in the direction of a "best practices" guide to converting legacy application variable caching where an external DAL is
involved, or does anyone have any strong opinions on thie best way to do
this?

Regards,

Duncan

Nov 16 '05 #2
Hi Duncan:

In a web application, you can use HttpContext.Current to reach the
Application collection during processing of a request. I.e.:

HttpContext.Current.Application["MyAppVar"];

Since this ties the DAL to working inside of a web application, I
generally abstract away the source of the cached data with a new
class (or classes, if need be). For a web application the custom cache
class will look into the Application or Cache collections, for a forms
application it might just look into a Hashtable it owns.

HTH,

--
Scott
http://www.OdeToCode.com
On Mon, 26 Jul 2004 12:25:34 +0100, "Duncan Welch"
<du**@ntpcl.f9.co.uk> wrote:
Good morning,

I have a classic ASP app that I'm converting to .NET. In the existing app
when accessing infrequntly changed data, it reads a database once a day, and
saves the results in an application variable.

I'm trying to replicate this in .NET, but I'm using a data access layer
(DAL) that's in a seperate project. Obviously, the DAL can't see the
application variables. I was thinking of passing the application state in
the constructor, but this seems like overkill.

Can someone please point me in the direction of a "best practices" guide to
converting legacy application variable caching where an external DAL is
involved, or does anyone have any strong opinions on thie best way to do
this?

Regards,

Duncan


Nov 16 '05 #3

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

Similar topics

5
by: Mark Kirkwood | last post by:
Dear all, Here is the first installment concerning ATA disks and RAID controller use in a database server. I happened to have a Solaris system to myself this week, so took the opportunity to use...
17
by: Woody Splawn | last post by:
I am finding that time after time I have instances where I need to access information in a variable that is public. At the same time, the books I read say that one should not use public variables...
20
by: Keith G. Murphy | last post by:
I'm trying to get a feel for what most people are doing or consider best practice. Given a mod_perl application talking to a PostgreSQL database on the same host, where different users are...
10
by: Jay Wolfe | last post by:
Hello, I'm trying to make sure I use best practices (and hence save myself some headaches) with the declaration and definition of global variables. Let's say I have an app with 30 files,...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
17
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is...
9
by: david | last post by:
I have a class with some business-logic and with every roundtrip, I need an instance of this class, so I have to create it, every time again. That doesn't seem very efficient. I thought it would...
4
by: skotapal | last post by:
Hello I manage a web based VB .net application. This application has 3 components: 1. Webapp (this calls the executibles) 2. database 3. business logic is contained in individual exe...
7
by: =?Utf-8?B?Q2hyaXMgQ2Fw?= | last post by:
We are considering moving from using several seperate webservers to a web farm. I was lookingg at implementing a start server to manage state for the web farm. The problem is, how do we keep...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.