Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I worked with JPA (Eclipselink implementation) and Hibernate. As I understand these two have great caching systems.

I am interested in caching in a Web application and in order to better understand the process I'm trying to implement something on my own.

Sadly, I cannot find any in depth documentation about this subject. I'm interested in things like high scalability, sharing memory on different machines and other important theoretical matters. Is there any tutorial or open project I could check out?

Thank you!

*LE: * I want to cache DB information in POJOs just like JPA or Eclipselink

share|improve this question

closed as not constructive by MichaelT, Glenn Nelson, GlenH7, ChrisF Feb 13 '13 at 21:08

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
I'd suggest ehcache as a good source of info and starting point. –  james Aug 10 '12 at 0:46
    
@james. Thank you! I'll look into int. –  TGM Aug 10 '12 at 4:43
    
You are aware that you can tell the client to cache resources by setting an expiry date? That might be a good place to start, as it will let you think about what you can cache and for how long. –  user1249 Aug 10 '12 at 12:28
add comment

3 Answers

Ehcache is a widely used open-source caching provider for Java with lots of features including replication, and works very well as a second-level cache for Hibernate.

Reading their doc and browsing their source should give you a good start.

share|improve this answer
add comment

If you're attempting to cache static web pages, then using nginx or Apache is the way to go. They'll server those files up faster then tomcat or jetty. Pages you generate once per startup, you should consider generating those and then moving the page to nginx/Apache/etc as part of your deploy process.

If you're talking about pages that don't change that often, then you can create filter and use oscache, or other caching library to store the page in memory. Make sure the filter you create is after whatever security you have, so your not serving cached pages to the world.

It's not covered much because you don't normally get enough return on the investment. Most Web Aplication pages change to much to be good candidates for cacheing.

share|improve this answer
    
Thank you! However I'm interested in caching java objects which contain information retrieved from the db. –  TGM Aug 10 '12 at 4:43
add comment

You can use memcached http://memcached.org/

there is a java client on memcached.

You can save the db object in memcached and achieve your purpose.

Ref: http://sacharya.com/using-memcached-with-java/

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.