• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Bear Bibeault
  • paul wheaton
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Mikalai Zaikin
  • Piet Souris
Bartenders:

How do you achieve caching in Java based application?

 
Ranch Hand
Posts: 240
2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you develop a Java based web application, how do you achieve caching nowadays?
I've studied Caching in Hibernate, there were 1st level cache, 2nd level cache and Query level cache.  Is that all about caching?
I want to know about the real time applications, is Caching achieved by using third party software?
Is caching part separate from the application code, like a load balancer?
Or it is something that you create a separate class where you use Collection to save the data?

Thanks in advance.
 
Bartender
Posts: 7520
172
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Caching can take many forms. You could create your own cache using data structures in your code (maybe using collections, maybe using other classes), or you could use a 3rd party library (like JBoss Cache or EhCache), or you could use an external caching server like Memcache or Redis.
 
Arun Singh Raaj
Ranch Hand
Posts: 240
2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
May I know which one is the most preferable way among you've given, to create cache nowadays?
And I want to know where does the cache reside, is it stored into the db?
 
Tim Moores
Bartender
Posts: 7520
172
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

May I know which one is the most preferable way among you've given, to create cache nowadays?


That can't be answered in general, it depends on the circumstances.

And I want to know where does the cache reside, is it stored into the db?


In memory. In a way, caches ARE databases, but their contents are not persisted. If the applications powers down, whatever was in the cache is lost - so the app needs to take care of filling the cache at startup time, or during the lifetime of the app.
 
Saloon Keeper
Posts: 15140
345
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember, caching is one of the hardest issues in computer science.

The other three are naming things and off-by-one errors.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:

May I know which one is the most preferable way among you've given, to create cache nowadays?


That can't be answered in general, it depends on the circumstances.

And I want to know where does the cache reside, is it stored into the db?


In memory. In a way, caches ARE databases, but their contents are not persisted. If the applications powers down, whatever was in the cache is lost - so the app needs to take care of filling the cache at startup time, or during the lifetime of the app.



Of coincidence, this is basically a cache set up for J2EE server API that I wrote, most cache I've heard of are as being said here, not part of the server API

Ramfile API doc
https://www.scribd.com/document/472437350/javax-servlet-Ramfile-Javadoc

Source code to insert into server source
https://www.scribd.com/document/470554983/javax-servlet-Ramfile-Interface-and-org-apache-catalina-core-RAMfileArray

I'm discussing it in other threads
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic