• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

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

 
Ranch Hand
Posts: 184
  • 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: 5330
143
  • 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: 184
  • 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: 5330
143
  • 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.
 
Saloon Keeper
Posts: 9988
207
  • 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.
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!