thanks Gerardo..This is a very efficient approach..However, I feel wrt my app, I might face some implementation difficulties...
1) I will give a brief explanation on this. Whether to update cache or not is decided by query and not by time.
The first query gives me a series of numbers like resulset row1-> 56, resultset row2-> 34 and so on. Everytime I take the count of rows that has value greater then cache's max value..eg 56 here. If count is more then zero, that means report needs to be updated.
So, I was thinking that with every request, this query should be executed. So essentially I want to execute this query before "getReport" for every request.something like
But then, it will again increase amont of time threads have to wait. The database operations are such that there are fewer inserts/updates but more reads.
So, in this case is this approach more feasible or running "updateReport" in background? Also, how do I run "updateReport" in background in spring? I guess I would have to implement "updateReport" in class that extends Runnable or something like that.
2) You also mentioned in TestControllerServlet:-
I guess, here "tcoReport" and "tco" are class level variables and not local variables inside "onSubmit" method. Essentially, I will be using
same instance of "TestControllerOutput" ie tco for every requests. Am I right?
Sorry for a very long post.