• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Enable caching at Spring application

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

We are using spring at our web application and there is a situation where I need caching.

There is a function working with billing system and take very long time until retrieving all the bills info , I need to call this service once per server starting and later at any user session I can use the response for this function without calling it again.

I.e

1 - Server start up at 11 Jan 2016 , List<bills> bills = longTimeService(); // actual connecting to back end.
2- User login at 15 Jan 2016 , retrieve the cached bills //without calling longTimeService(); again.

So how to save this bills list so it can be cached ?
 
Saloon Keeper
Posts: 26549
187
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
From the sound of it, the easiest way to "cache" this information would be in the database itself.

If you're assembling the bills from complex calculations, compute the results (you can even possibly do this offline) and then have your app do a simple fetch item. If the issue is a lot of table join overhead, create a de-normalized table with the essential information already assembled in it (which is how noSQL gets its speed). Once again, by having everything available in a single simple row fetch. Which is usually quite fast.

Actual caching is something you'd be more likely to want if you're querying the same records repeatedly and frequently. For predictable sequential retrieval, there's also pre-fetching.
 
Ramy Nady
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:From the sound of it, the easiest way to "cache" this information would be in the database itself.



Unfortunately this is a MW service called from our application through WAS MQ.
I.e our application doesn't have access to DB directly - we access it though MW - which is indeed access the related back end system.
 
Tim Holloway
Saloon Keeper
Posts: 26549
187
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
MW? When I Google that I get a local construction company.

A cache is, theoretically speaking, a local database which can be accessed faster than the primary database can be. Actually, one example of this is the class of database proxy servers, where one or more local apps connect (usually via JDBC) to the local DB proxy, which fulfills requests from its local cache where possible, and only queries the primary (external) database when there's a cache miss.

If your application is hard-coded to retrieve data via a web service or JMS request instead of JDBC, you might be able to find a similar proxy service available for those protocols. I think, in fact that maybe MQ itself may have that option. The other alternative would be to tune the backend server.

I'm not mentioning Spring caches because that would imply making application changes plus it would potentially bind a lot of data directly to the app, which reduces both flexibility and manageability. You'd normally only find an in-app cache to be an advantage if the app's working set data was fairly small and slow-changing.



 
Ramy Nady
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:MW? When I Google that I get a local construction company.


I mean middle ware check link http://www.acronymfinder.com/Middleware-(MW).html

We don't have control over other back end teams to asking doing such caching , for that we are seeking to do this from our application side.





 
reply
    Bookmark Topic Watch Topic
  • New Topic