472,335 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Class design - minimize DB calls

I have a User class that takes a UserID as a parameter in the constructor,
and then looks up the record in the DB and stores the values into the User
class properties. Often when a page loads, I have to grab the same User
several times to display information on several different places on the
page.

In order to minimize the connections to the database when its the same User,
in this instance, I'd like for my User class to store Users as they are
created into some object that is Cached. When the User constructor is
called, it would check this Cache object and then use the Cached data in the
properties, rather than make a call to the database.

I am thinking of using Hashtable, with the UserId as the key, and the User
object for the Userid as the value. But this approach seems rather awkward.
Does anyone have ideas or suggestions? I would appreciate your input.

Thanks

--
[[((hillarie))]]

To reply by email, remove ".SPAMBLOCK" from email address
Nov 17 '05 #1
1 993
If you need to keep some infor during the lifetime of one request use
HttpContext.Current.Items

George.

"H Branyan" <hb****************@merc.mercer.edu> wrote in message
news:bo*************@ID-92475.news.uni-berlin.de...
I have a User class that takes a UserID as a parameter in the constructor,
and then looks up the record in the DB and stores the values into the User
class properties. Often when a page loads, I have to grab the same User
several times to display information on several different places on the
page.

In order to minimize the connections to the database when its the same User, in this instance, I'd like for my User class to store Users as they are
created into some object that is Cached. When the User constructor is
called, it would check this Cache object and then use the Cached data in the properties, rather than make a call to the database.

I am thinking of using Hashtable, with the UserId as the key, and the User
object for the Userid as the value. But this approach seems rather awkward. Does anyone have ideas or suggestions? I would appreciate your input.

Thanks

--
[[((hillarie))]]

To reply by email, remove ".SPAMBLOCK" from email address

Nov 17 '05 #2

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

Similar topics

8
by: Franz Steinhaeusler | last post by:
Hello, (in wxPython) I want to redirect the SetStatusText to an own method (change the text somewhat) and then call the SetStatusText of...
3
by: Angus Comber | last post by:
Hello I am attempting to build a set of classes which handle telephony. Basically the handling of phone calls. My design currently has two...
15
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design...
11
by: dimension | last post by:
If my intentions are to create objects that encapsulates data rows in a table, is it better to use a Struct or Class? Based on what i read, if my...
3
by: Don | last post by:
If you have a form that calls another form via the following code: Dim myForm as Form2 myForm = New Form2 myForm.Owner = Me MyForm.ShowDialog ...
19
by: Chocawok | last post by:
Some of the classes in my app are graphical. To encapsulate the graphical side of things I had created a class called "sprite" which holds a bit...
1
by: D-Someone | last post by:
I am re-posting this message as originially it did not get a single response.. Any ideas? -------------- I am trying to come up with a good...
4
by: Deus402 | last post by:
I am designing an employer database, and I had thought that my tabledesign was pretty sound, but a new revelation has ruined my design. What I...
1
by: Angus | last post by:
Hi all I have a design which models a telephone system. Roughly the design has these two items: device class which models an extension on the...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

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.