缓存结果集
我的应用程序将使用数据源 bean 从 MySql 检索县列表。由于每次我可以将国家/地区列表存储为某个全局 bean 中的列表时,所有页面都可能使用相同的记录集,因此在这种情况下是安全的。我可以随时刷新列表...但是当事情变得更加复杂时,最好的策略是什么,即更具可扩展性的解决方案?
使用内存数据库? 第三部分缓存结果集?
没有找到,可能是因为我对这个主题还很陌生。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ResultSet
与数据库连接相关联,它是一个相当短暂的构造,并且不适合缓存。我建议使用 EhCache 来缓存您的结果。它是一种内存缓存机制(具有溢出到磁盘的选项,以及跨集群分发的选项)。它与 Spring 集成得非常好(通过
EhCacheManagerFactoryBean
和EhCacheFactoryBean
)。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
andEhCacheFactoryBean
).如果国家/地区列表几乎从不更新,请填写 FastMap应用程序启动时,地图键为两个字母的国家/地区缩写,值为其他您要为每个国家/地区存储的信息。否则,请使用内存数据库缓存,例如 EhCache 和 Memcached。
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.
使用 CachedRowSet。它可以被视为 ResultSet,但是它不需要维护与数据库的连接。
Use CachedRowSet. It can be treated like a ResultSet, but it doesn't need to maintain a connection to the database.