Reputation: 1440
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.
Upvotes: 4
Views: 2282
Reputation: 3860
Use CachedRowSet. It can be treated like a ResultSet, but it doesn't need to maintain a connection to the database.
Upvotes: 0
Reputation: 1419
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.
Upvotes: 0
Reputation: 403441
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
).
Upvotes: 2