AppEngine Memcache
High performance scalable web applications often use a distributed in-memory data cache in front of or in place of robust persistent storage for some tasks.
The cache is global and is shared across the application's frontend, backend, and all of its services and versions.
Session data, user preferences, and other data returned by queries for web pages are good candidates for caching.
Values can expire from the memcache at any time, and can be expired prior to the expiration deadline set for the value.
Service levels
App Engine supports two levels of the memcache service:
Shared memcache is the free default for App Engine applications. It provides cache capacity on a best-effort basis and is subject to the overall demand of all the App Engine applications using the shared memcache service.
Dedicated memcache provides a fixed cache capacity assigned exclusively to your application. It's billed by the GB-hour of cache size and requires billing to be enabled. Having control over cache size means your app can perform more predictably and with fewer reads from more costly durable storage.
Both memcache service levels use the same API.
NOTE: Whether shared or dedicated, memcache is not durable storage. Keys can be evicted when the cache fills up, according to the cache's LRU policy. Changes in the cache configuration or datacenter maintenance events can also flush some or all of the cache.
Limits
The maximum size of a cached data value is approximately 73 bytes.
A key cannot be larger than 250 bytes. In the Java runtime, keys that are objects or strings longer than 250 bytes will be hashed. (Other runtimes behave differently.)
The "multi" batch operations can have any number of elements. The total size of the call and the total size of the data fetched must not exceed 32 megabytes.
A memcache key cannot contain a null byte.
Available APIs
Low-level Memcache API and the JCache specification.
Low-level API
- Expose more cache statistics, such as the amount of time since the least- recently-used entry was accessed, and the total size of all items in the cache.
Atomically increment and decrement integer counter values.
Check and set operations to conditionally store data.
Perform memcache operations asynchronously, using the AsyncMemcacheService
The low-level API provides
and
for accessing memcache service. This API is richer than the one provided by JCache.
JCache
JCache provides a map-like interface to cached data. You store and retrieve values in the cache using keys. Keys and values can be of any Serializable type or class.
References
https://cloud.google.com/appengine/docs/standard/java/memcache/
https://cloud.google.com/appengine/docs/standard/java/memcache/using