2012-04-16 22:50



Can I write to the memcache from Go and read it from Java (on appengine)?

From the memcache viewer it looks like the answer is no, since there are keys of type "Java string" and "Go string". What about sharing []byte?

Are web-hooks and the data store the only ways of communicating between Java and Go on Appengine?


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • drexlz0623 drexlz0623 9年前

    I don't know the answer to your question, but you will find part of it in method makePbKey in MemcacheSerialization.java. That shows how Java takes an Object and makes a key out of it.

    Likewise, in file appengine/memcache/memcache.go, you can see how AppEngine for Go makes a key out of Item.Key (type string). See GetMulti, where each key is converted from a string to a []byte via a simple cast.

    So, the final answer to your question depends on you finding a path through both mkPbKey and GetMulti that results in the same key. It seems to me like if you give Java a key of type String, and it has length less than 250, and you remember to put "" before and after your keys in Go, it might work. (But reading mkPbKey makes me wonder how it reacts to a string which has 200 code points in it, all of which result in multi-byte encodings in UTF-8. Seems like it will produce a bigger key than they are expecting.)

    点赞 评论 复制链接分享