473,569 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2713
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******** ******@TK2MSFTN GP10.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.Cur rent to reach the
Application collection during processing of a request. I.e.:

HttpContext.Cur rent.Applicatio n["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
2203
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 it as a "control". In this post I used the ATA RAID controller merely to enable UDMA 133 for an oldish x86 machine, the effect of any actual RAID...
17
5510
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 too much - that it's bad programming practice. Is there an easy way to deal with this? I would like to do things in the "Best Practices" way but...
20
6570
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 logging onto the web server using LDAP for authentication, do most people 1) have the web server connecting to the database using its own user account...
10
7005
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, including main.cpp I have global variables that need defining in main.cpp and declaring in all other files in. The way I've seen it done is to...
59
7464
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 the recordset opens a table. When I write Set rst = db.OpenRecordset("MyTable",dbOpenTable, dbReadOnly) I get an error. I believe it's...
17
3528
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 populated when a user scans a label. The other is ScanDate - a date/time field that should equal the date/time of the scan (e.g. 7/31/2006 5:00:00...
9
7284
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 be 'better' to store an instance of this class in a session-variable, so it's available all the time and needs to be instanced only once. Is...
4
1510
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 application that get called in a sequence to do some heavy calculations (mainly DB operations with in memory datasets)
7
5625
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 the Application object consistent between all web servers? As far as I read the state server only manages session state and not application state. ...
0
7703
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...
0
7926
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. ...
0
8132
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...
0
6286
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...
1
5514
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...
0
5222
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...
1
2116
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
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
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...

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.