You will see a couple issues here:
[1] Database access can be agonizingly slow -- milliseconds and up
[2] In-Memory access can be very, very fast -- on the order of
microseconds.
[3] Memory space is finite, though most servers nowadays can hold up to
2Gb. But you need to think about what you are going to do when your
cache size approaches some limit. You will either need some decision
mechanism to toss things out of cache and some mechanism to decide when
to add things to cache.
[4] Caching breeds concurrency issues. What do you do when the Customer
record you have cached in-memory is updated by someone else on the
server but in the meantime your web app has made changes to its copy?
You have both "detection" and "resolution" problems to solve here.
Problems [3] and [4] are the main headaches of highly-scalable systems
and become moreso (particularly [4]) when the load is distributed across
multiple servers.
-=- D. J.
Rick Reumann wrote:
> For example say you have various people in a database and have
> their name, phone number, address, etc. stored in there.
> Where I work we don't do the database select statements in the
> jsp pages but in seperate classes out on the server but obviously
> call them from the jsp pages.
>
> I seem to think it's convenient then to create a vector of , for
> example, "people" objects and then iterate through the vector
> getting the information I need from each object..getPhoneNumber,
> getAddress, etc. Is this a good way to get this information from a
> database?
>
> I'm also curious if it's worth an extra step of accessing the
> database first in order to get a row count that you could then use to
> give the vector a size? (will this even be worth it for a small
> database that maybe only has only 1000 rows?)
> Another method I've used is setting up an array of hashtables and
> then calling up each hash table and getting phone number,
> address, etc. that way. Is this better?
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets