class documentation

class Cache(object):

View In Hierarchy

Represents a data content cache made available to the module space of a specific .Template object.

New in version 0.6: .Cache by itself is mostly a container for a .CacheImpl object, which implements a fixed API to provide caching services; specific subclasses exist to implement different caching strategies. Mako includes a backend that works with the Beaker caching system. Beaker itself then supports a number of backends (i.e. file, memory, memcached, etc.)

The construction of a .Cache is part of the mechanics of a .Template, and programmatic access to this cache is typically via the .Template.cache attribute.

Method get Retrieve a value from the cache.
Method get​_or​_create Retrieve a value from the cache, using the given creation function to generate a new value.
Method invalidate Invalidate a value in the cache.
Method invalidate​_body Invalidate the cached content of the "body" method for this template.
Method invalidate​_closure Invalidate a nested <%def> within this template.
Method invalidate​_def Invalidate the cached content of a particular <%def> within this template.
Method set Place a value in the cache.
Instance Variable id Return the 'id' that identifies this cache.
Instance Variable impl Provide the .CacheImpl in use by this .Cache.
Instance Variable starttime Epochal time value for when the owning .Template was first compiled.
Method __init__ Undocumented
Method ​_ctx​_get​_or​_create Retrieve a value from the cache, using the given creation function to generate a new value.
Method ​_get​_cache​_kw Undocumented
Method ​_load​_impl Undocumented
Instance Variable ​_def​_regions Undocumented
Instance Variable template Undocumented
def get(self, key, **kw):
Retrieve a value from the cache.
Parameters
keythe value's key.
**kwcache configuration arguments. The backend is configured using these arguments upon first request. Subsequent requests that use the same series of configuration values will use that same backend.
def get_or_create(self, key, creation_function, **kw):
Retrieve a value from the cache, using the given creation function to generate a new value.
def invalidate(self, key, **kw):
Invalidate a value in the cache.
Parameters
keythe value's key.
**kwcache configuration arguments. The backend is configured using these arguments upon first request. Subsequent requests that use the same series of configuration values will use that same backend.
def invalidate_body(self):
Invalidate the cached content of the "body" method for this template.
def invalidate_closure(self, name):

Invalidate a nested <%def> within this template.

Caching of nested defs is a blunt tool as there is no management of scope -- nested defs that use cache tags need to have names unique of all other nested defs in the template, else their content will be overwritten by each other.

def invalidate_def(self, name):
Invalidate the cached content of a particular <%def> within this template.
def set(self, key, value, **kw):
Place a value in the cache.
Parameters
keythe value's key.
valuethe value.
**kwcache configuration arguments.
id =

Return the 'id' that identifies this cache.

This is a value that should be globally unique to the .Template associated with this cache, and can be used by a caching system to name a local container for data specific to this template.

impl =

Provide the .CacheImpl in use by this .Cache.

This accessor allows a .CacheImpl with additional methods beyond that of .Cache to be used programmatically.

starttime =

Epochal time value for when the owning .Template was first compiled.

A cache implementation may wish to invalidate data earlier than this timestamp; this has the effect of the cache for a specific .Template starting clean any time the .Template is recompiled, such as when the original template file changed on the filesystem.

def __init__(self, template, *args):

Undocumented

def _ctx_get_or_create(self, key, creation_function, context, **kw):
Retrieve a value from the cache, using the given creation function to generate a new value.
def _get_cache_kw(self, kw, context):

Undocumented

def _load_impl(self, name):

Undocumented

_def_regions: dict =

Undocumented

template =

Undocumented