正如我的问题标题所说,Memcache是否应该与Google云终端配合良好? 在本地,它可以在我的应用程序中使用JCache存储键/值对,并在Google Cloud Endpoints API方法中读取它。
当我上传我的应用程序并在云端运行它时,它返回null就像我发现we can't access sessions from inside of cloud endpoints时的情况一样......
我做错了什么或谷歌云端点也不应该访问缓存?
我真的需要在我的应用程序和云端点之间安全地共享一些令牌,我不想从数据存储区写入/读取(这些是易失性令牌......)。有什么想法吗?
答案 0 :(得分:1)
端点绝对适用于使用built-in API的memcache。我刚刚在API方法中尝试了以下简单的片段,并按预期看到了递增的值:
String key = "key";
Integer cached = 0;
MemcacheService memcacheService = MemcacheServiceFactory.getMemcacheService();
memcacheService.setErrorHandler(new StrictErrorHandler());
cached = (Integer) memcacheService.get(key);
if (cached == null) {
memcacheService.put(key, 0);
} else {
memcacheService.put(key, cached + 1);
}
这应该适合您,除非您对JCache有特定要求。