Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Improving performance of a REST Webservice

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

I have a RESTFul webservice that goes to the database to fetch some data, The data is very static in nature and changes like once a month or so.

Still to fetch the data from DB it takes the service about 300ms, I was wondering is thare any way in which I can cache the data on server and make the service fetch it from there so that the time spent blocking on DB and IO is reduced.

And also is there any way in which the chache can be refreshed when new data is added ?

Thanks,
Vivek
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure you can use a cache; some popular Java caching libraries are listed in http://faq.javaranch.com/java/CachingStrategies.

You'll need to add the logic to update the cache yourself, though - no way to do it automatically.
 
Saloon Keeper
Posts: 24541
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ORMs such as Hibernate are good for this. They cache transparently and you can also plug in enhanced caching components if you need support for such things as external database updates that would invalidate what's in cache.
 
Vivek K Singh
Ranch Hand
Posts: 85
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim and Ulf. While looking online memcached came up, need to see if it is too much of an overkill for the problem else its going to be hibernate cache.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic