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, **kw)[source]¶ Bases:
cement.core.cache.CacheHandler
This class implements the Cache Handler interface. It provides a caching interface using the pylibmc library.
-
_config
(key)[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
()[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, **kw)[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, **kw)[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, fallback=None, **kw)[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)[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.
-
set
(key, value, time=None, **kw)[source]¶ Set a value in the cache for the given
key
. Any additional keyword arguments will be passed directly to the pylibmc set function.Parameters: - key (str) – The key of the item in the cache to set.
- value – The value of the item to set.
Keyword Arguments: time (int) – The expiration time (in seconds) to keep the item cached. Defaults to expire_time as defined in the applications configuration.
-