• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pagination & Session Management

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

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.


Do post your suggestions on the same.


Regards
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had done something similar before. I would also suggest looking at some of the java caching solutions. Some are open source.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you cache primary keys instead of complete records? Then you could retrieve individual records by key or use a range of keys to hit the db again. Might be worth the extra effort ... or not.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If user needs 91 to 110 records, Is it 2 web service calls ?
 
Mohit Sinha
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Raj,

Your are right. The second set of records from 101-200 is a separate webservice call.
Also the search results retrieved would be user specific & not shared amongst other users.

Regards,
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
ashish jadhav
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean to say,stored records in cache and write to DB after specific time interval
eg. time interval= 2sec.
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic