Interface MemcacheService

All Superinterfaces:
BaseMemcacheService

public interface MemcacheService extends BaseMemcacheService
The Java API for the App Engine Memcache service. This offers a fast distributed cache for commonly-used data. The cache is limited both in duration and also in total space, so objects stored in it may be discarded at any time.

Note that null is a legal value to store in the cache, or to use as a cache key. Although the API is written for Objects, both keys and values should be Serializable, although future versions may someday accept specific types of non-Serializable Objects.

The values returned from this API are mutable copies from the cache; altering them has no effect upon the cached value itself until assigned with one of the put methods. Likewise, the methods returning collections return mutable collections, but changes do not affect the cache.

Methods that operate on single entries, including increment(java.lang.Object, long), are atomic, while batch methods such as getAll(java.util.Collection<T>), putAll(java.util.Map<T, ?>, com.google.appengine.api.memcache.Expiration, com.google.appengine.api.memcache.MemcacheService.SetPolicy), and deleteAll(java.util.Collection<T>) do not provide atomicity. Arbitrary operations on single entries can be performed atomically by using putIfUntouched(java.lang.Object, com.google.appengine.api.memcache.MemcacheService.IdentifiableValue, java.lang.Object, com.google.appengine.api.memcache.Expiration) in combination with getIdentifiable(java.lang.Object).

Increment has a number of caveats to its use; please consult the method documentation.

An ErrorHandler configures how errors are treated. The default error handler is an instance of LogAndContinueErrorHandler. In most cases this will log the underlying error condition and emulate cache-miss behavior instead of throwing an error to the calling code. For example, it returns null from get(Object).

A less permissive alternative is StrictErrorHandler, which will instead throw a MemcacheServiceException to expose any errors for application code to resolve.

To guarantee that all MemcacheServiceException are directed to the error handler use a ConsistentErrorHandler such as ErrorHandlers.getConsistentLogAndContinue(Level) or ErrorHandlers.getStrict().