cement.ext.ext_memcached
Cement memcached extension module.
Note This extension has an external dependency on pylibmc
. Cement
explicitly does not include external dependencies for optional
extensions.
In Cement
>=3.0.8
you must includecement[memcached]
in your applications dependencies.In Cement
<3.0.8
you must includepylibmc
in your applications dependencies.
- class cement.ext.ext_memcached.MemcachedCacheHandler(*args: Any, **kw: Any)[source]
Bases:
CacheHandler
This class implements the Cache Handler interface. It provides a caching interface using the pylibmc library.
- class Meta[source]
Bases:
Meta
Handler meta-data.
- _config(key: str) Any [source]
This is a simple wrapper, and is equivalent to:
self.app.config.get('cache.memcached', <key>)
.- Parameters:
key (str) – The key to get a config value from the ‘cache.memcached’ config section.
- Returns:
The value of the given key.
- Return type:
unknown
- _fix_hosts() None [source]
Useful to fix up the hosts configuration (i.e. convert a comma-separated string into a list). This function does not return anything, however it is expected to set the hosts value of the
[cache.memcached]
section (which is what this extension reads for it’s host configution).- Returns:
None
- _setup(*args: Any, **kw: Any) None [source]
Called during application initialization and must
setup
the handler object making it ready for the framework or the application to make further calls to it.- Parameters:
app (instance) – The application object.
- delete(key: str, **kw: Any) bool [source]
Delete an item from the cache for the given
key
. Any additional keyword arguments will be passed directly to the pylibmc delete function.- Parameters:
key (str) – The key to delete from the cache.
- get(key: str, fallback: Any = None, **kw: Any) Any [source]
Get a value from the cache. Any additional keyword arguments will be passed directly to pylibmc get function.
- Parameters:
key (str) – The key of the item in the cache to get.
- Keyword Arguments:
fallback – The value to return if the item is not found in the cache.
- Returns:
The value of the item in the cache, or the
fallback
value.- Return type:
unknown
- purge(**kw: Any) None [source]
Purge the entire cache, all keys and values will be lost. Any additional keyword arguments will be passed directly to the pylibmc
flush_all()
function.