cinder_data.store module¶
-
class
cinder_data.store.Store(host, namespace='', cache=None)¶ Bases:
objectA central store for all CRUD like activilty for models.
Initialise the store.
Parameters: - host (string) – The host of your api, e.g. http://localhost:8000
- namespace (string, optional) – An aditional name space to append to the host, e.g. api/v1
- cache (
cinder_data.cache.Cache, optional) – An instance of your chosen caching system that must be must adhear to thecinder_data.cache.Cacheinterface.
-
find_all(model_class, params={})¶ Return an list of models from the API and caches the result.
Parameters: - model_class (
cinder_data.model.CinderModel) – A subclass ofcinder_data.model.CinderModelof your chosen model. - params (dict, optional) – Description
Returns: A list of instances of you model_class or and empty list.
Return type: list
- model_class (
-
find_record(model_class, record_id, reload=False)¶ Return a instance of model_class from the API or the local cache.
Parameters: - model_class (
cinder_data.model.CinderModel) – A subclass ofcinder_data.model.CinderModelof your chosen model. - record_id (int) – The id of the record requested.
- reload (bool, optional) – Don’t return the cached version if reload==True.
Returns: An instance of model_class or None.
Return type: - model_class (
-
peek_all(model_class)¶ Return a list of models from the local cache.
Parameters: model_class ( cinder_data.model.CinderModel) – A subclass ofcinder_data.model.CinderModelof your chosen model.Returns: A list of instances of you model_class or and empty list. Return type: list
-
peek_record(model_class, record_id)¶ Return an instance of the model_class from the cache if it is present.
Parameters: - model_class (
cinder_data.model.CinderModel) – A subclass ofcinder_data.model.CinderModelof your chosen model. - record_id (int) – The id of the record requested.
Returns: An instance of model_class or None.
Return type: - model_class (