Currently we are working on displaying user specific search results. Ideally for any pagination strategies we can choose from either a cache based (store resultsets in session) or query based (database call for each subset of rows to display). Each has it own merit.
In our situation we have to display 20 records each time to the user. In our case to fetch the data subsets we have to make a web service call & not a database call. This web service also accepts a parameter of the number of records to fetch. Since making a web service call everytime the user clicks next & fetch the 20 records to be shown on the screen will have a high latency & we also cannot opt for fetching all the records & storing it in session as we would be having a very high number of users accessing the system & storing all the resultsets in the session may not scale well.
With this regard we are thinking of adopting a hybrid approach where in we get 100 records, store it in the session & serve the user out of those first lot of 100 records from the session. Say when the user requests for data from 101-120 we make anther web service call , fetch the next set of 100 records & slam it into the same session variable replacing the first lot of 100. Now say the user accesses the 91-100 we make a web service call again to fetch the first set of 100 records. So the web service calls to fetch the records will only happen at intervals of 91-100,101-110 & for all other requests like 71-80 or say 121-130 likes the data will be served from the session.
Sounds like a reasonable strategy. When it comes time to retrieve the next block of 100 records, you may want to do that in a separate thread, so that the request for rows 91-100 doesn't have to wait until rows 101-200 have been retrieved.
It may also be advantageous to use a single shared cache rather than saving the record in the session. Particularly if your application is one in which multiple users are likely to be viewing the same records. Also it may be easier to manage the cache if it's in one place, so you can expire older entries, or reduce or expand the size of the cache based on available memory or performance tuning parameters. And yes, check out the available java caching solutions to save yourself some time.
Hi mohit, i am also working on same stub of web service in java.i created one web service which insert data in DB.but i want to set time interval to insert data in DB in specific time interval.can you please help me? how set time interval in java web service??