views:

79

answers:

2

My app will retrieve a countylist from MySql using a datasource bean. Since all pages will potentially use the same recordset every time I could store the countrylist as a List in some global bean, safe in this case. I could manage to refresh the list any time I want... but when things become more complex what is the best strategy for it, the more scalable solution?

Use a in memory database? A 3rd part cached resultset?

didnt found one, probably because I'm to new to the subject.

+1  A: 

ResultSet is tied to the database connection, it's a fairly ephemeral construct, and not suitable for caching.

I recommend using EhCache to cache your results. It's an in-memory cache mechanism (with options to overflow to disk, and options to distribute across a cluster). It integrates very nicely with Spring (via EhCacheManagerFactoryBean and EhCacheFactoryBean).

skaffman
not much time to test, but I will give a try! just saw a little article explaining its basics, but the basic need a bit of preparation. anyway, its said to be scalable and like you said goes well with spring. thanks!
Ruben Trancoso
A: 

If the country list is updated almost never, fill a FastMap on application startup with the map keys being the two letter country abbreviations and the values being other info you want to store for each country. Otherwise, use an in-memory DB cache such as EhCache and Memcached.

Amir Moghimi