class Cache(object):
Represents a data content cache made available to the module
space of a specific .Template
object.
.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 |
Parameters | |
key | the value's key. |
**kw | cache 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. |
Parameters | |
key | the value's key. |
**kw | cache 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. |
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.
Parameters | |
key | the value's key. |
value | the value. |
**kw | cache configuration arguments. |
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.
Provide the .CacheImpl
in use by this .Cache
.
This accessor allows a .CacheImpl
with additional
methods beyond that of .Cache
to be used programmatically.
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.