Win a copy of Spring in Action (5th edition) this week in the Spring 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

How do you achieve caching in Java based application?  RSS feed

 
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • 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.
 
Saloon Keeper
Posts: 5041
134
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 176
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Posts: 5041
134
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
Bartender
Posts: 9494
184
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!