473,379 Members | 1,511 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,379 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 1015
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 wx.Frame. But I have a little problem 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 main classes - one dealing with the device and the...
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 decision. This really is a toy project written for...
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 objects will simply have get and set methods,...
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 and you minimize the second form, the first form...
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 map and knows how to draw itself etc. The...
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 design for a web service that has some user logic...
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 guess i really need is a way to uniquely identify...
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 telephone system. The device constructor takes...
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...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.