Package com.google.appengine.api.memcache (2.0.0)

Provides fast but unreliable data storage, also accessible via a JCache interface. Objects may be stored in the cache with an explicit expiration time, but may also be evicted before that expiration to make room for newer, more active entries.

The cache is accessed via a MemcacheService object, obtained from the MemcacheServiceFactory. It offers the cache as a map from key Object to value Object.

In the Development Server, the system property memcache.maxsize can be set to limit the available cache, taking values like "100M" (the default), "10K", or "768" (bytes).

Because the cache offers best-effort data storage, by default most errors are treated as a cache miss. More explicit error handling can be installed via MemcacheService#setErrorHandler(ErrorHandler). See Also: com.google.appengine.api.memcache.MemcacheService, The Memcache Java API in the Google App Engine Developer's Guide., JCache API

Classes

ConsistentLogAndContinueErrorHandler

Similar to the deprecated LogAndContinueErrorHandler but consistently handles all back-end related errors.

ErrorHandlers

Static utility for getting built-in ErrorHandlers.

Expiration

Expiration specifications on MemcacheService#putAll(Map , Expiration) and MemcacheService#put(Object, Object, Expiration) operations.

Expiration has resolution to one second, although a milliseconds factory constructor is provided for convenience.

IMemcacheServiceFactoryProvider

Factory provider for IMemcacheServiceFactory.

Note: This class is not intended for end users.

LogAndContinueErrorHandler

The default error handler, which will cause most service errors to behave as though there were a cache miss, not an error.

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

MemcacheSerialization

Static serialization helpers used by MemcacheServiceImpl

This class is thread-safe.

MemcacheSerialization.ValueAndFlags

Tuple of a serialized byte array value and associated flags to interpret that value. Used as the return from MemcacheSerialization#serialize.

MemcacheService.CasValues

A holder for compare and set values. expiration and newValue can be null.

MemcacheServiceFactory

The factory by which users acquire a handle to the MemcacheService.

MemcacheServicePb

MemcacheServicePb.AppOverride

MemcacheServicePb.AppOverride.Builder

MemcacheServicePb.ItemTimestamps

MemcacheServicePb.ItemTimestamps.Builder

MemcacheServicePb.MemcacheBatchIncrementRequest

MemcacheServicePb.MemcacheBatchIncrementRequest.Builder

MemcacheServicePb.MemcacheBatchIncrementResponse

MemcacheServicePb.MemcacheBatchIncrementResponse.Builder

MemcacheServicePb.MemcacheDeleteRequest

MemcacheServicePb.MemcacheDeleteRequest.Builder

MemcacheServicePb.MemcacheDeleteRequest.Item

MemcacheServicePb.MemcacheDeleteRequest.Item.Builder

MemcacheServicePb.MemcacheDeleteResponse

MemcacheServicePb.MemcacheDeleteResponse.Builder

MemcacheServicePb.MemcacheFlushRequest

MemcacheServicePb.MemcacheFlushRequest.Builder

MemcacheServicePb.MemcacheFlushResponse

MemcacheServicePb.MemcacheFlushResponse.Builder

MemcacheServicePb.MemcacheGetRequest

MemcacheServicePb.MemcacheGetRequest.Builder

MemcacheServicePb.MemcacheGetResponse

MemcacheServicePb.MemcacheGetResponse.Builder

MemcacheServicePb.MemcacheGetResponse.Item

MemcacheServicePb.MemcacheGetResponse.Item.Builder

MemcacheServicePb.MemcacheHotKey

MemcacheServicePb.MemcacheHotKey.Builder

MemcacheServicePb.MemcacheIncrementRequest

MemcacheServicePb.MemcacheIncrementRequest.Builder

MemcacheServicePb.MemcacheIncrementResponse

MemcacheServicePb.MemcacheIncrementResponse.Builder

MemcacheServicePb.MemcacheServiceError

MemcacheServicePb.MemcacheServiceError.Builder

MemcacheServicePb.MemcacheSetRequest

MemcacheServicePb.MemcacheSetRequest.Builder

MemcacheServicePb.MemcacheSetRequest.Item

MemcacheServicePb.MemcacheSetRequest.Item.Builder

MemcacheServicePb.MemcacheSetResponse

MemcacheServicePb.MemcacheSetResponse.Builder

MemcacheServicePb.MemcacheStatsRequest

MemcacheServicePb.MemcacheStatsRequest.Builder

MemcacheServicePb.MemcacheStatsResponse

MemcacheServicePb.MemcacheStatsResponse.Builder

MemcacheServicePb.MergedNamespaceStats

MemcacheServicePb.MergedNamespaceStats.Builder

StrictErrorHandler

A strict error handler, which will throw MemcacheServiceException or InvalidValueException for any service error condition.

Interfaces

AsyncMemcacheService

An asynchronous version of MemcacheService. All methods return immediately and provide Futures as their return values.

BaseMemcacheService

Methods that are common between MemcacheService and AsyncMemcacheService.

ConsistentErrorHandler

A marker interface to indicate that all MemcacheServiceException exceptions should be handled by ErrorHandler#handleServiceError(MemcacheServiceException). This interface was added to enable handling MemcacheServiceException thrown by the various MemcacheService#put(Object, Object) methods while preserving backward compatibility with ErrorHandler which did not handle such cases.

ErrorHandler

Handles errors raised by the MemcacheService, registered with MemcacheService#setErrorHandler(ErrorHandler).

The default error handler is an instance of LogAndContinueErrorHandler. In most cases, this will log exceptions without throwing, which looks like a cache-miss behavior to the caller. A less permissive alternative is StrictErrorHandler, which will throw a MemcacheServiceException to surface errors to callers.

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

IMemcacheServiceFactory

The factory by which users acquire a handle to the MemcacheService.

MemcacheService

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, are atomic, while batch methods such as #getAll, #putAll, and #deleteAll do not provide atomicity. Arbitrary operations on single entries can be performed atomically by using #putIfUntouched in combination with #getIdentifiable.

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().

MemcacheService.IdentifiableValue

Encapsulates an Object that is returned by #getIdentifiable. An IdentifiableValue can later be used in a #putIfUntouched operation.

MemcacheService.ItemForPeek

...

MemcacheServicePb.AppOverrideOrBuilder

MemcacheServicePb.ItemTimestampsOrBuilder

MemcacheServicePb.MemcacheBatchIncrementRequestOrBuilder

MemcacheServicePb.MemcacheBatchIncrementResponseOrBuilder

MemcacheServicePb.MemcacheDeleteRequest.ItemOrBuilder

MemcacheServicePb.MemcacheDeleteRequestOrBuilder

MemcacheServicePb.MemcacheDeleteResponseOrBuilder

MemcacheServicePb.MemcacheFlushRequestOrBuilder

MemcacheServicePb.MemcacheFlushResponseOrBuilder

MemcacheServicePb.MemcacheGetRequestOrBuilder

MemcacheServicePb.MemcacheGetResponse.ItemOrBuilder

MemcacheServicePb.MemcacheGetResponseOrBuilder

MemcacheServicePb.MemcacheHotKeyOrBuilder

MemcacheServicePb.MemcacheIncrementRequestOrBuilder

MemcacheServicePb.MemcacheIncrementResponseOrBuilder

MemcacheServicePb.MemcacheServiceErrorOrBuilder

MemcacheServicePb.MemcacheSetRequest.ItemOrBuilder

MemcacheServicePb.MemcacheSetRequestOrBuilder

MemcacheServicePb.MemcacheSetResponseOrBuilder

MemcacheServicePb.MemcacheStatsRequestOrBuilder

MemcacheServicePb.MemcacheStatsResponseOrBuilder

MemcacheServicePb.MergedNamespaceStatsOrBuilder

Stats

Statistics from the cache, available via MemcacheService#getStatistics()

Enums

MemcacheSerialization.Flag

Values used as flags on the MemcacheService's values.

MemcacheService.SetPolicy

Cache replacement strategies for MemcacheService#put operations, indicating how to handle putting a value that already exists.

MemcacheServicePb.MemcacheDeleteResponse.DeleteStatusCode

MemcacheServicePb.MemcacheGetResponse.GetStatusCode

MemcacheServicePb.MemcacheIncrementRequest.Direction

MemcacheServicePb.MemcacheIncrementResponse.IncrementStatusCode

MemcacheServicePb.MemcacheServiceError.ErrorCode

MemcacheServicePb.MemcacheSetRequest.SetPolicy

MemcacheServicePb.MemcacheSetResponse.SetStatusCode

Exceptions

InvalidValueException

Thrown when a cache entry has content, but it cannot be read. For example:

  • An attempt to MemcacheService#increment a non-integral value
  • Version skew between your application and the data in the cache, causing a serialization error.

MemcacheServiceException

An exception for backend non-availability or similar error states which may occur, but are not necessarily indicative of a coding or usage error by the application. Also used for MemcacheService#put(Object, Object) when the combined key and value size is too large.

In most cases these will be given to the ErrorHandler to resolve. Use ConsistentErrorHandler if in all cases this exception should be directed to the ErrorHandler.