Adam Bien's Weblog

Monday Jan 11, 2010

What is the difference between pooling and caching?

The difference is simple. Pooling is appropriate if you don't care about the internal state of a particular class / type. Pooling is mainly motivated by technical reasons like performance, latency or memory optimizations.
Caching is all about state. You want to retain the state for performance reasons and store (cache) it in objects between calls. So instead loading the state from the database in every request, you could cache the data between requests in valid objects.

Pooled objects are in an undefined state, but the state of cached objects is always well defined.

[See Page 20 (EJB: Introducing Consistency) in Real World Java EE Patterns - Rethinking Best Practices book]


[my tweets]  Rss My book: Real World Java EE - Rethinking Best Practices

Kommentare:

Since I'm interested in db connection state (specifying validate query, so connection gets validated before being returned to the caller), is my db connection pool then actually connection cache?

Gesendet von Stevo Slavic am January 22, 2010 at 01:03 AM CET #

Senden Sie einen Kommentar:
  • HTML Syntax: Ausgeschaltet
Interviews/About
My Recent Book
Java One 2009
CommunityOne East N.Y.C
JavaONE 2008 Interview
Search
...the last 150 posts
...the last 10 comments
greenfire.dev.java.net
Links
my.netbeans.org
Visitors
License