Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

RESTful Web service with JAX-RS - pagination and caching  RSS feed

 
Hervé Guidetti
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm planning to develop a REST Web service using JAX-RS.
I have a core banking system that gives me a list of entries (I cannot change it).

Pagination : I would like to be able to get the list of entries (example 400 entries) and send some of them to the web service client. When I ask the web service for the first time (for the first page), the entries are retrieved from the core banking system, cache them somewhere, and return the 10 first entries. When I ask the second page, I would like to retrieve the 400 entries from the cache and return the next set of 10 entries (next page).

My question is : where should I put this cache ?
Is it OK to use the HttpSession since RESTful web service should be stateless ?
What would you advice otherwise ?

Thanks in advance for your advices.

Hervé
 
michael cheung
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Restful api is stateless. (http://en.wikipedia.org/wiki/Representational_State_Transfer) You shouldn't use http session to store the state. You can do caching, but that should done in a distributed cache. The way i do pagination is doing through using a query parameter or header passing the page number and size. Hope this help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!