Stay organized with collections Save and categorize content based on your preferences.
This page describes how to use the legacy bundled services and APIs. This API can only run in first-generation runtimes in the App Engine standard environment. If you are updating to the App Engine Python 3 runtime, refer to the migration guide to learn about your migration options for legacy bundled services.An application can use a Context to control its caching policy. Context
also offers convenient asynchronous APIs for Memcache and URL Fetch integrated into NDB's asynchronous facilities; in particular, the Memcache API supports auto-batching.
Returns a Future
. To wait for the flushing to finish, call this object's wait()
method.
bool
indicating whether the entity with this key should be cached in the in-context cache. May be None
(meaning use default_cache_policy
).
bool
indicating if it should use the Datastore. May be None
(meaning use default_datastore_policy
).
bool
indicating if it should be cached. May be None
(meaning use default_memcache_policy
).
None
, which uses default_memcache_timeout_policy
.
Arguments
bool
indicating whether the entity with this key should be cached in the in-context cache. May be None
.
Arguments
bool
indicating whether the entity with this key should be stored in the persistent Datastore. May be None
.
Arguments
bool
indicating whether the entity with this key should be cached in the in-context cache. May be None
.
Arguments
Key
instance argument and returns the desired memcache timeout in seconds (or returns zero to use the default timeout). May be None
.
The full list of methods is found in the Memcache API reference. The list below highlights some of the more commonly used methods:
add()
.
Client
cas()
(compare-and-swap).
decr()
.
delete()
.
get()
.
Returns a Future
whose return value is the value retrieved from memcache or None
.
gets()
.
incr()
.
replace()
.
set()
.
fetch().
If not in a transaction, the callback is called immediately.
In a transaction, multiple callbacks may be registered and will be called once the transaction commits in the order in which they were registered. If the transaction fails, the callbacks will not be called.
If a callback raises an exception, it bubbles up normally. This means: If the callback is called immediately, any exception it raises will bubble up immediately. If the call is postponed until commit, remaining callbacks will be skipped and the exception will bubble up through the transaction()
call. (However, the transaction is already committed at that point.)
Arguments
True
if this Context represents a transaction, False
otherwise.
_use_cache
class variable on the entity's model class; if there is one, return it. Otherwise, return None
.
_use_datastore
class variable on the entity's model class; if there is one, return it. Otherwise, return None
.
_use_memcache
class variable on the entity's model class; if there is one, return it. Otherwise, return None
.
_memcache_timeout
class variable on the entity's model class; if there is one, return it. Otherwise, return None
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This page outlines the use of legacy bundled services and APIs, which are compatible only with first-generation runtimes in the App Engine standard environment."],["A `Context` can be used by an application to control its caching policy, including setting cache, datastore, and memcache policies, as well as memcache timeout policies."],["`Context` provides asynchronous APIs for Memcache, supporting auto-batching, and URL Fetch, enabling efficient data retrieval and management."],["The `Context` also provides methods for transaction management, including queuing callbacks upon successful transaction commit and checking if the current context is within a transaction."],["The `Context` class offers various static methods for setting and checking policies such as default_cache_policy, default_datastore_policy, default_memcache_policy, and default_memcache_timeout_policy."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4