3

Is it possible (and does it make sense) to use the JDO Level 2 Cache for the Google App Engine Datastore?

First of all, why is there no documentation about this on Google's pages? Are there some problems with it? Do we need to set up limits to protect our memcache quota?

According to DataNucleus on Stackoverflow, you can set the following persistence properties:

 datanucleus.cache.level2.type=javax.cache
 datanucleus.cache.level2.cacheName={cache name}

Is that all? Can we choose any cache name?

Other sources on the Internet report using different settings.

Also, it seems we need to download the DataNucleus Cache support plugin. Which version would be appropriate? And do we just place it in WEB-INF/lib or does it need more setup to activate it?

Community
  • 1
  • 1
Thilo
  • 257,207
  • 101
  • 511
  • 656
  • Have you gotten anywhere with this? I am trying to decide between using JDO level 2 cache and the JCache implementation that the google docs mention, and there seems to be a dearth of docs/discussion on this topic. – tempy Mar 23 '10 at 23:40
  • 1
    No. I have not gotten anywhere. I am thinking about using the low-level datastore API (or an alternative library on top of that). JDO is getting too much of a black-box for me. – Thilo Mar 24 '10 at 01:18
  • 1
    We seem to belong to a large, unhappy club =/ – tempy Mar 24 '10 at 18:19
  • I got this to work. Tips: 1. download version 1.1.1 of the jar 2. add these to your jdoconfig.xml: datanucleus.cache.level2.type=javax.cache datanucleus.cache.level2.cacheName={cache name} 3. make anything you want cached serializable 4. call makePersistent on anything you want cached, even if it's already persistent. 5. wrap everything in a transaction (this is required because under the covers it uses async JCache) see: http://www.datanucleus.org/products/datanucleus/jdo/cache.html#javax_cache – eeeeaaii Oct 11 '12 at 11:40

3 Answers3

3

Before you can figure this out, you have to answer one question:

Which version of DataNucleus are you using?

Everything on this post has to do with the old version of the plugin -- v1. Only recently has the Google Plugin for Eclipse supported v2 of the DataNucleus plugin for AppEngine (which is basically the conduit between AppEngine and the DataNucleus Core).

I'd recommend upgrading to v2 of the Datanucleus plugin for AppEngine -- if you're using Eclipse, it's easy -- there's a UI for it that allows you to select v1 or v2. Just go to your Project properties and find the App Engine settings and look for "Datanucleus JDO/JPA version".

Plus, you have to make a change to your jdo-config.xml. Specifically, you have to change just one property:

<property name="javax.jdo.PersistenceManagerFactoryClass" value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>

SO -- Once you've upgraded to v2, this is how you specify caching (an addition to jdoconfig.xml):

<property name="datanucleus.cache.level2.type" value="jcache"/>
<property name="datanucleus.cache.level2.cacheName" value="NameItWhateverYouWant"/>

At this point, caching should happen automatically every time you put and get using a PersistenceManager. Hooray!

Jake Toronto
  • 3,524
  • 2
  • 23
  • 27
1

No known problems with anything to do with L2 caching and GAE/J. If people have problems then perhaps they ought to report them to Google. Set the cache name to what you wish. Anything put into memcache has to be Serializable, obviously, since that is what memcache does. Yes, you need the datanucleus-cache plugin (ver 1.x), and put it in the same place as any other DN jars. One day Google will update to use DN 2.x

DataNucleus
  • 15,497
  • 3
  • 32
  • 37
  • Why does the Entity class have to be Serializable? DataNucleus can already turn it into a low-level datastore.Entity, which is already Serializable. – Thilo Jan 08 '10 at 23:40
0

It seems to have problems instead: I tried (with JPA) and I got the error someone else already reported: http://code.google.com/p/datanucleus-appengine/issues/detail?id=163

luciano
  • 101
  • 1
  • 5