As with other services, App Engine includes two Java interfaces to the memcache service. One is a proprietary interface that provides direct access to the features of the service. The other is an implementation of JCache, an interface standard proposed by JSR 107.
As of this writing, JSR 107 is not a ratified standard, and the recommended way to use it on App Engine is in flux. So for now, we’ll just consider the proprietary interface. For more information on using the JCache interface with App Engine, consult the App Engine documentation.
The memcache service Java API allows for the use of any serializable object as the key or the value of a key-value pair stored in the cache. Keys whose serialized form is larger than 250 bytes are hashed to 250 bytes. Values can be up to one megabyte in size.
In many cases, you can make a JPA data class serializable simply by
declaring that the class implements
Serializable, with no
other changes. If you’re using the low-level datastore API, the
Entity class and all of the property value classes implement
With App Engine’s memcache service Java API, you interact with the
service using a
MemcacheService object, which you get from
The basic operations are available as methods of
import com.google.appengine.api.memcache.MemcacheService; import com.google.appengine.api.memcache.MemcacheServiceFactory; // ... List<String> ...