Cache

Sunday, 12 October 2000
The need for speed (www.useit.com/alertbox/...) remains on the internet. A lot of users are still surfing with a low speed connection.
  1. So, small web pages with a fast download time will remain top priority for a good performance.
  2. Factor number two is a good database performance. Technical database optimisation is nice, but it's even more fun not to access the database less times.
OO can help here, by caching objects. This can be done in both GUI layer as well as in the object layer. Attention

Caching is a way of storing derived data. The original data in the database may change, while the object still contains the old values.

Here are a number of caching techniques, with increasing performance benefit and accompanying risk.

Local variable

The lightest for of caching is an object in a local variable. The object exists just as long as the method runs.

Request variable

For information between several servlets and JSP pages an instance in the request is most appropriate. The object exists until the request has finished, when the user has new output on his screen.

Session variable

This is a more heavy form, suitable for information that won't change during the session.

The object remains to exist, during the whole session, as long as the user remains on the website. This form already has some real risk of outdated information.

Object cache

This is the most heavy form of caching. Objects remain to exist, independant of sessions. This can be done in the object layer with a static Hashmap in a Class. Multiple users can share the same object.

The object has the largest risk to get outdated.

Till next week!
Nut