class documentation

class MemoizedHasCacheKey(HasCacheKey, HasMemoized):

Known subclasses: sqlalchemy.orm.attributes.QueryableAttribute, sqlalchemy.orm.mapper.Mapper, sqlalchemy.orm.util.AliasedInsp, sqlalchemy.orm.util.Bundle, sqlalchemy.sql.expression.ClauseElement

View In Hierarchy

Undocumented

Method ​_generate​_cache​_key return a cache key.

Inherited from HasCacheKey:

Class Variable inherit​_cache Indicate if this .HasCacheKey instance should make use of the cache key generation scheme used by its immediate superclass.
Class Method ​_generate​_cache​_attrs generate cache key dispatcher for a new class.
Class Method ​_generate​_cache​_key​_for​_object Undocumented
Method ​_gen​_cache​_key return an optional cache key.
Class Variable __slots__ Undocumented
Class Variable ​_hierarchy​_supports​_caching private attribute which may be set to False to prevent the inherit_cache warning from being emitted for a hierarchy of subclasses.
Class Variable ​_is​_has​_cache​_key Undocumented
@HasMemoized.memoized_instancemethod
def _generate_cache_key(self):

return a cache key.

The cache key is a tuple which can contain any series of objects that are hashable and also identifies this object uniquely within the presence of a larger SQL expression or statement, for the purposes of caching the resulting query.

The cache key should be based on the SQL compiled structure that would ultimately be produced. That is, two structures that are composed in exactly the same way should produce the same cache key; any difference in the structures that would affect the SQL string or the type handlers should result in a different cache key.

The cache key returned by this method is an instance of .CacheKey, which consists of a tuple representing the cache key, as well as a list of .BindParameter objects which are extracted from the expression. While two expressions that produce identical cache key tuples will themselves generate identical SQL strings, the list of .BindParameter objects indicates the bound values which may have different values in each one; these bound parameters must be consulted in order to execute the statement with the correct parameters.

a _expression.ClauseElement structure that does not implement a ._gen_cache_key method and does not implement a .traverse_internals attribute will not be cacheable; when such an element is embedded into a larger structure, this method will return None, indicating no cache key is available.