Hi, Be careful with the cron job: you may lose some of your updates if gae has some trouble between some updates and the cron job. There is no guarantee from Google on that point:
see "Under rare circumstances, values may also disappear from the cache prior to expiration for reasons other than memory pressure. While memcache is resilient to server failures, memcache values are not saved to disk, so a service failure may cause values to become unavailable." at http://code.google.com/appengine/docs/java/memcache/overview.html#How_Cached_Data_Expires Anyway, more simply if the cache is too loaded, some values are discarded. So, here again you may lose values. So, I would encourage either a direct write-through in addition to cache write. You can do it via a synchronous / async I/O from the transaction or via a task that you queue. regards didier On Apr 19, 7:40 pm, blue <[email protected]> wrote: > Every action on my app will require the user to view and update their user > object, but other users will have the opportunity to update other user > objects as well. So, my question is, what is the cheapest way to do this? > > The best way I have found to do this is: > 1) read user from memcache (or datastore if not > there and put into memcache) > 2) modify user object > 3) get from memcache again and see if version has changed > 4) write to memcache with new version or throw error if version is different > 5) have a cron job write batches to the datastore if needed > > Most of the time a user will end up with 2 gets from memcache and 1 set to > memcache. > > The other option I have tried was transactions, but that was way too > expensive -- datastore writes on every request. > I also tried sessions, but that was also very expensive -- datastore writes > on every request. > > Does anyone have a better solution? -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
