My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SecondLevelCache  
Second level cache information.
Phase-Support, Manual
Updated Aug 2, 2009 by treeder

Introduction

Enabling the second level cache in SimpleJPA is extremely simple and provides huge performance benefits. The second level cache is shared across all EntityManager sessions obtained by an EntityManagerFactory.

Any cache can be supported by implementing com.spaceprogram.simplejpa.cache.CacheFactory that can create com.spaceprogram.simplejpa.cache.Cache's.

Benefits

  • Much faster queries. When you run a query on SimpleDB, it returns a list of id's to the items. A second request is required to retrieve the attributes for that item. Using the second level cache can avoid the additional request resulting in a huge performance improvement.

Drawbacks

  • More memory usage. This can be tuned to your liking though so it's generally a non issue.
  • Stale data. If another application changes the data in SimpleDB, then your application may have stale data in the cache. If this is likely to happen, you'll want to reduce your caches Time to Live settings.

Using the second level cache

This only requires two things:

That's it. Nothing else is required. Simple huh?

Comment by avio...@gmail.com, Jun 28, 2011

The link in, "Create a cache configuration file and put it in your classpath. You can see an example config file here" isn't working.

Comment by vinylmat...@gmail.com, Nov 29, 2011

Doesn't seem to work with OneToMany? relationship. Queries still occur when getting the objects on the many side of the relationship.


Sign in to add a comment
Powered by Google Project Hosting