Pergunta

As my question title says, is Memcache supposed to play well with Google cloud endpoints? Locally it does, I can store a key / value pair using JCache in my application and read it from within a Google Cloud Endpoints API method.

When I upload my application and run it on the cloud it returns null exactly as the way it happens when I've found out that we can't access sessions from inside of cloud endpoints...

And I doing something wrong or Google cloud endpoints isn't supposed to access the cache as well?

I really need to share some tokens safely between my application and cloud endpoints and I don't want to write / read from the Datastore (those are volatile tokens...). Any ideas?

Foi útil?

Solução

Endpoints definitely works with memcache, using the built-in API. I just tried the following trivial snippet within an API method and saw the incrementing values as expected:

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);
}

This should work for you, unless you have a specific requirement for JCache.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top