Search code examples
google-app-enginejdodatanucleus

How to use Memcache with JDO/Datanucleus on Appengine (Gradle)


I was recently looking at how to set up caching with JDO on Appengine, and there doesn't seem to be any good documentation. How do you make use of Memcache to avoid unnecessary hits to the datastore? I am using Android Studio / Gradle.


Solution

  • After some poking around, I came up with the following working solution.

    Add the following lines to config files:

    jdoconfig.xml <property name="datanucleus.cache.level2.type" value="jcache"/> <property name="datanucleus.cache.level2.cacheName" value="Anything"/>

    build.gradle (for appengine module) compile 'net.sf.jsr107cache:jsr107cache:1.1' compile 'com.google.appengine:appengine-jsr107cache:1.9.17' compile 'org.datanucleus:datanucleus-cache:3.1.3'

    Of course, your mileage may vary, depending on your specific JDO setup.