skip to Main Content

My entity is @Cached and that’s fine.

But, for a cron job, I don’t want ofy().save.entities() to touch Memcache. The reason is, I save thousands of objects, and I don’t need them hot for retrieval.

Also, I keep getting weird exceptions, such as:

java.lang.reflect.InvocationTargetException
at com.google.appengine.runtime.Request.process-326a59f97d0f0252 (Request.java)
at sun.reflect.GeneratedMethodAccessor21.invoke (Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:42)
at com.googlecode.objectify.cache.MemcacheServiceRetryProxy.invoke (MemcacheServiceRetryProxy.java:68)
at com.sun.proxy.$Proxy9.putAll (Unknown Source)
at com.googlecode.objectify.cache.KeyMemcacheService.putAll (KeyMemcacheService.java:91)
at com.googlecode.objectify.cache.EntityMemcache.empty (EntityMemcache.java:323)
at com.googlecode.objectify.cache.CachingAsyncDatastoreService$5.trigger (CachingAsyncDatastoreService.java:445)
at com.googlecode.objectify.cache.TriggerFuture.isDone (TriggerFuture.java:87)
at com.googlecode.objectify.cache.TriggerFuture.get (TriggerFuture.java:102)
at com.googlecode.objectify.cache.PendingFutures.completeAllPendingFutures (PendingFutures.java:57)
at com.googlecode.objectify.ObjectifyService$2.close (ObjectifyService.java:120)
at com.googlecode.objectify.ObjectifyFilter.doFilter (ObjectifyFilter.java:49)

and:

com.google.appengine.api.memcache.MemcacheServiceException: Memcache putAll: Unknown exception setting 2 keys
at com.google.appengine.api.memcache.MemcacheServiceApiHelper$RpcResponseHandler.handleApiProxyException (MemcacheServiceApiHelper.java:69)
at com.google.appengine.api.memcache.AsyncMemcacheServiceImpl$RpcResponseHandlerForPut.handleApiProxyException (AsyncMemcacheServiceImpl.java:349)
at com.google.appengine.api.memcache.MemcacheServiceApiHelper$1.absorbParentException (MemcacheServiceApiHelper.java:111)
at com.google.appengine.api.utils.FutureWrapper.handleParentException (FutureWrapper.java:52)
at com.google.appengine.api.utils.FutureWrapper.get (FutureWrapper.java:91)
at com.google.appengine.api.utils.FutureWrapper.get (FutureWrapper.java:89)
at com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet (MemcacheServiceImpl.java:26)
at com.google.appengine.api.memcache.MemcacheServiceImpl.putAll (MemcacheServiceImpl.java:115)
at com.googlecode.objectify.cache.KeyMemcacheService.putAll (KeyMemcacheService.java:91)
at com.googlecode.objectify.cache.EntityMemcache.getAll (EntityMemcache.java:242)
at com.googlecode.objectify.cache.CachingAsyncDatastoreService.get (CachingAsyncDatastoreService.java:252)

and:

com.google.appengine.api.memcache.MemcacheServiceException: Memcache getAll: exception getting multiple keys
at com.google.appengine.api.memcache.MemcacheServiceApiHelper$RpcResponseHandler.handleApiProxyException (MemcacheServiceApiHelper.java:69)
at com.google.appengine.api.memcache.MemcacheServiceApiHelper$1.absorbParentException (MemcacheServiceApiHelper.java:111)
at com.google.appengine.api.utils.FutureWrapper.handleParentException (FutureWrapper.java:52)
at com.google.appengine.api.utils.FutureWrapper.get (FutureWrapper.java:91)
at com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet (MemcacheServiceImpl.java:26)
at com.google.appengine.api.memcache.MemcacheServiceImpl.getAll (MemcacheServiceImpl.java:64)
at com.googlecode.objectify.cache.KeyMemcacheService.getAll (KeyMemcacheService.java:83)
at com.googlecode.objectify.cache.EntityMemcache.cacheGetAll (EntityMemcache.java:365)
at com.googlecode.objectify.cache.EntityMemcache.putAll (EntityMemcache.java:296)
at com.googlecode.objectify.cache.CachingAsyncDatastoreService$3.success (CachingAsyncDatastoreService.java:279)
at com.googlecode.objectify.cache.CachingAsyncDatastoreService$3.success (CachingAsyncDatastoreService.java:268)

So, my question is, how do I save using Objectify without hitting Memcache?

And/or, how do I prevent those exceptions from happening?

2

Answers


  1. You can disable the global cache for an operation:

    ofy().cache(false).save()...

    More details here

    Login or Signup to reply.
  2. You can use ofy().cache(false) but you have to be careful about this.

    On save, Objectify clears cache entries. On load, Objectify checks memcache and if the value is not present, saves it in memcache for later. Generally you want to maintain this clearing behavior on save otherwise you risk leaving stale entries in the cache. When loading seldom-accessed entities in bulk, use ofy().cache(false).load()... and memcache will remain unpolluted.

    Or just remove @Cache from the entity class.

    I don’t know what to say about your exception; it comes from the bowels of GAE and not Objectify.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search