I have a Google App Engine project wherein I am trying to cache some data in my APIs.
Below is how I try to use the cache in my code
try {
CacheFactory cacheFactory = CacheManager.getInstance()
.getCacheFactory();
cache = cacheFactory.createCache(Collections.emptyMap());
LOG.info("Cache Created");
cache.put(key, value);
} catch (CacheException ex) {
LOG.error("cache exception encountered:{}", ex);
}
I get the following exception
com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call memcache.Set in a thread that is neither the original request thread nor a thread created by ThreadManager
at com.google.apphosting.api.ApiProxy$CallNotFoundException.foreignThread(ApiProxy.java:800) ~[appengine-api-1.0-sdk-1.9.54.jar:na]
at com.google.apphosting.api.ApiProxy$1.get(ApiProxy.java:175) ~[appengine-api-1.0-sdk-1.9.54.jar:na]
at com.google.apphosting.api.ApiProxy$1.get(ApiProxy.java:172) ~[appengine-api-1.0-sdk-1.9.54.jar:na]
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:89) ~[appengine-api-1.0-sdk-1.9.54.jar:na]
at com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet(MemcacheServiceImpl.java:26) ~[appengine-api-1.0-sdk-1.9.54.jar:na]
at com.google.appengine.api.memcache.MemcacheServiceImpl.put(MemcacheServiceImpl.java:69) ~[appengine-api-1.0-sdk-1.9.54.jar:na]
at com.google.appengine.api.memcache.stdimpl.GCache.put(GCache.java:157) ~[appengine-api-1.0-sdk-1.9.54.jar:na]
The app engine dependency that I have added in my pom is
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.54</version>
</dependency>
What am I doing wrong here.