[Opensource] SimpleDateFormat
Michael Rimov
rimovm at centercomp.com
Sun Mar 16 04:05:35 PST 2003
At 11:44 AM 3/13/2003 -0500, you wrote:
>So Michael, how would I in a wrapper make use of the cache you've
>already setup in JDBCUtil?
I wouldn't worry about direct use I think JDBCUtil is too much in flux to
externally rely on it.
To rolly your own Create a static org.apache.commons.collections.LRUMap
keyed by Locale that store SimpleDateFormat Objects. when you need to
format against a particular locale [ControllerRequest.getLocale()], look
it up in the LRUMap, and if it exists use it, if it doesn't exist, create a
new one for the locale and store it in the LRUMap. Make sure you
synchronize against the Map for each access.
Depending on your capabilities, you probably don't need to have the map
larger that 5.
HTH!
-Mike
[For those that are scratching their heads regarding the greek I just
spoke, LRUMap is a java.util.Map implementation that keeps X items in store
and whenever more are stored, the map ejects items based upon the least
recently used algorithm. So in essence, it's a built in simple cache
implementation useful for certain tasks]
More information about the Opensource
mailing list