I have several drop down list on my JSP page and their values are retrieved from the database every time the page is requested. I find this to be inefficient. So I would like to know how did you guys implement the caching mechanism for these values? How do you find out if the value in the database has been changed?
I've done it/seen it done in several different ways.
1) Never invalidate (have to restart container!)
2) Time-based invalidation (e.g reread after every 5 or 10 minutes)
3) Select count(1), invalidate when the count changes (only applicable for lists where rows are added only, and only useful when the database is much faster returning the count than returning the full amount of data)
After reading Marc Fleury's Blue whitepaper touting the great caching in JBoss, I would like to know if/how anyone has leveraged the built in caching of the container...
Thanks for your input guys.
I have an approach for this problem, I want your comments:
1.- Get the ResultSet from DB
2.- Create a RowSet(a vector of vectors) from that ResultSet
3.- Serialize the RowSet in the webserver
4.- Deserialize the RowSet every time it be displayed in JSP.
5.- Refresh the RowSet every time that first session starts
6.- Refresh the RowSet every time its underliying data change.
Do you see any problem with this approach?.
See for example Cache taglib in Coldtags suite: