内存缓存和带有数据流的自定义 DoFn

memcache and a custom DoFn with dataflow

我正在尝试将 google 内存缓存与数据流结合使用。我基本上想将数据转换为内存缓存。是否可以在数据流内部使用 google memcache api?

我收到以下错误: java.util.concurrent.ExecutionException: com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'memcache' or call 'Set()' was not found. com.google.appengine.api.utils.FutureWrapper.setExceptionResult(FutureWrapper.java:65)

这是代码行:

AsyncMemcacheService asyncCache =     MemcacheServiceFactory.getAsyncMemcacheService("namespace");
asyncCache.put("key", "value", Expiration.byDeltaSeconds(100000)).get();

我认为 memcache 是 App Engine 的一部分,不能在 App Engine 之外直接访问。因此,您将无法直接从 Dataflow 访问它。您可以做的是创建一个充当代理的 App Engine 服务,并从 Dataflow 向该服务发送请求。