In the database, I have a definition table that is read from the application once upon starting. This definition table rarely changes, so it makes sense to read it once and restart the application every time it changes.
However, after the table is read (put into a ResultSet), it will be read by multiple handlers running in their own threads.
How do you suggest to accomplish this?
My idea was to populate a CachedRowSet, and then create a copy of this set (through the createCopy() method) for each handler every time a new request comes.
Do you think this is wise? Does this offer a good performance?
Thanks.
I think it is a pattern to read the configuration table into a static data structure (
ConcurrentHashMap) and then let the threads to look it up.You can ensure that there is no write race at startup by populating the reference map from a
Servlet.init()– it is guaranteed to execute once per servlet.