469,626 Members | 1,610 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

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 962
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Franz Steinhaeusler | last post: by
3 posts views Thread by Angus Comber | last post: by
15 posts views Thread by Steven T. Hatton | last post: by
11 posts views Thread by dimension | last post: by
19 posts views Thread by Chocawok | last post: by
1 post views Thread by Angus | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.