Cement core cache module.
Base class that all Cache Handlers should sub-class from.
This class defines the Cache Handler Interface. Classes that implement this handler must provide the methods and attributes defined below.
Implementations do not subclass from interfaces.
from cement.core import cache class MyCacheHandler(object): class Meta: interface = cache.ICache label = 'my_cache_handler' ...
The label (or type identifier) of the interface.
Interface validator function.
The _setup function is 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_obj – The application object. Returns:
Deletes a key/value from the cache.
Parameters: key – The key in the cache to delete. Returns: True if the key is successfully deleted, False otherwise. Return type:
Get the value for a key in the cache. If the key does not exist or the key/value in cache is expired, this functions must return ‘fallback’ (which in turn must default to None).
- key – The key of the value stored in cache
- fallback – Optional value that is returned if the cache is expired or the key does not exist. Default: None
Unknown (whatever the value is in cache, or the fallback)
Clears all data from the cache.
Set the key/value in the cache for a set amount of time.
- key – The key of the value to store in cache.
- value – The value of that key to store in cache.
- time (
None) – A one-off expire time. If no time is given, then a default value is used (determined by the implementation).
Validates a handler implementation against the ICache interface.