Are subsequent calls to appengine.NewContext(r) equivalent

41 views
Skip to first unread message

John Beckett

unread,
Jun 23, 2016, 10:34:33 AM6/23/16
to google-appengine-go
I'm busy implementing a caching layer in an AppEngine application, and from what I have found goon (github.com/mjibson/goon) seems the best option.  However to use it, one has to pass in the *http.Request instead of the more common context.Context.  Goon then uses the request to generate a new context.

My concern is that (for many reasons) I already have a context created in my app with a call to appengine.NewContext(r), so now there will be two separate calls to generate a context.  Is this likely to be a problem?  

Alternatively I could fork goon and simply change one of the functions ( NewGoon(r) ) to instead take in a context.Context, which would remove any possible issues.  However I'm then stuck with a fork that I have to maintain, which I'm not terribly excited about.  I'd appreciate any suggestions or feedback on this, especially from anyone that has dealt with this already.


alex

unread,
Jun 23, 2016, 10:37:56 AM6/23/16
to John Beckett, google-appengine-go
>  goon (github.com/mjibson/goon) seems the best option

I found nds to be much better as it's a drop-in replacement. Very simple to use.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Beckett

unread,
Jun 23, 2016, 11:01:34 AM6/23/16
to alex, google-appengine-go
Thanks for the suggestion Alex.  It looks like a much simpler library to use. Have you had any issues with nds in production?  

alex

unread,
Jun 23, 2016, 11:04:50 AM6/23/16
to John Beckett, google-appengine-go
No issues at all so far, as long as you're aware of what it's doing - caching in memcache. Just something to remember when manipulating data directly in datastore viewer, plus memcache limits.

But that isn't related to a specific package anyway.

Dave Day

unread,
Jun 23, 2016, 8:45:45 PM6/23/16
to google-appengine-go
Yes, it's totally fine to have make multiple calls to NewContext for a single request.

It is not guaranteed to return the same context.Context each time (in fact, the current implementation returns different ones) but every return value will behave the same way for a given request. The function is also "cheap" to call, so there's no real performance disadvantage either.
Reply all
Reply to author
Forward
0 new messages