英文:
Sharing Memcache on Gae with Go and Java
问题
我可以从Go写入memcache并从Java(在appengine上)读取吗?
从memcache查看器来看,答案似乎是否定的,因为有类型为“Java string”和“Go string”的键。那么[]byte类型的共享呢?
在Appengine上,Web钩子和数据存储是Java和Go之间通信的唯一方式吗?
谢谢
英文:
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?
Thanks
答案1
得分: 3
我不知道你问题的答案,但你可以在MemcacheSerialization.java的makePbKey方法中找到部分答案。这显示了Java如何将一个对象转换为键。
同样,在文件appengine/memcache/memcache.go中,你可以看到AppEngine for Go如何将Item.Key(类型为字符串)转换为键。在GetMulti中,每个键都通过简单的转换从字符串转换为[]byte。
所以,你的问题的最终答案取决于你找到一条路径,通过mkPbKey和GetMulti,可以得到相同的键。在我看来,如果你给Java一个类型为String的键,并且它的长度小于250,并且在Go中在你的键之前和之后记得加上"",它可能会起作用。(但是阅读mkPbKey让我想知道它对一个包含200个代码点的字符串的反应,所有代码点在UTF-8中都会产生多字节编码。似乎它会产生一个比他们预期的更大的键。)
英文:
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.)
1: http://code.google.com/p/googleappengine/source/browse/trunk/java/src/main/com/google/appengine/api/memcache/MemcacheSerialization.java "MemcacheSerialization.java"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论