views:

57

answers:

2

I'm using latest versions of Spring Framework and Hibernate. I know how I can create custom version of MessageSource. But what would be best way to serve i18n messages. Because if I query database every time application needs internationalization, it will cause huge amount traffic to database, and often queries will just return same answer for same queries.

I would like to hear about good ways to implement this? Would it be good way to store all messages to memory or what would be best way to effectively serve messages?

A: 

If you're talking about static messages only, storing all of them into memory looks acceptable. For an advanced solution, you could consider using a caching framework like ehcache which integrates well with spring but that may be overkill depending on the amount of data you want to cache and the necessity to clear it on particular conditions.

Damien
+1  A: 

Because if I query database every time application needs internationalization, it will cause huge amount traffic to database, and often queries will just return same answer for same queries.

Consider using L2 caching and query caching. Entities to represent i18n messages seems to be good candidates for caching. And have a look at

Pascal Thivent