pylons.decorators.cache – Cache Decorators

Caching decorator

Module Contents

pylons.decorators.cache.beaker_cache(key='cache_default', expire='never', type=None, query_args=False, cache_headers=('content-type', 'content-length'), invalidate_on_startup=False, cache_response=True, **b_kwargs)

Cache decorator utilizing Beaker. Caches action or other function that returns a pickle-able object as a result.

Optional arguments:

None - No variable key, uses function name as key “cache_default” - Uses all function arguments as the key string - Use kwargs[key] as key list - Use [kwargs[k] for k in list] as key
Time in seconds before cache expires, or the string “never”. Defaults to “never”
Type of cache to use: dbm, memory, file, memcached, or None for Beaker’s default
Uses the query arguments as the key, defaults to False
A tuple of header names indicating response headers that will also be cached.
If True, the cache will be invalidated each time the application starts or is restarted.

Determines whether the response at the time beaker_cache is used should be cached or not, defaults to True.


When cache_response is set to False, the cache_headers argument is ignored as none of the response is cached.

If cache_enabled is set to False in the .ini file, then cache is disabled globally.