Sodarcache Django API Documentation
This document contains Django API documentation for the backend plugin in the
sodarcache
app. Included are functionalities and classes intended to be used
by other applications.
Backend API
The backend API can be retrieved as follows.
from projectroles.plugins import get_backend_api
app_alerts = get_backend_api('sodar_cache')
Make sure to also enable sodar_cache
in the ENABLED_BACKEND_PLUGINS
Django setting.
- class sodarcache.api.SodarCacheAPI[source]
SodarCache backend API to be used by Django apps.
- classmethod delete_cache(app_name=None, project=None)[source]
Delete cache items. Optionallly limit to project and/or user.
- Parameters
app_name – Name of the app which sets the item (string)
project – Project object (optional)
- Returns
Integer (deleted item count)
- Raise
ValueError if app_name is given but invalid
- classmethod get_cache_item(app_name, name, project=None)[source]
Return cached data by app_name, name (identifier) and optional project. Returns None if not found.
- Parameters
name – Item name (string)
app_name – Name of the app which sets the item (string)
project – Project object (optional)
- Returns
JSONCacheItem object
- Raise
ValueError if app_name is invalid
- classmethod get_project_cache(project, data_type='json')[source]
Return all cached data for a project.
- Parameters
project – Project object
data_type – String stating the data type of the cache items
- Returns
QuerySet
- Raise
ValueError if data_type is invalid
- classmethod get_update_time(app_name, name, project=None)[source]
Return the time of the last update of a cache object as seconds since epoch.
- Parameters
name – Item name (string)
app_name – Name of the app which sets the item (string)
project – Project object (optional)
- Returns
Float
- classmethod set_cache_item(app_name, name, data, data_type='json', project=None, user=None)[source]
Create or update and save a cache item.
- Parameters
app_name – Name of the app which sets the item (string)
name – Item name (string)
data – Item data (dict)
data_type – String stating the data type of the cache items
project – Project object (optional)
user – User object to denote user triggering the update (optional)
- Returns
JSONCacheItem object
- Raise
ValueError if app_name is invalid
- Raise
ValueError if data_type is invalid
- classmethod update_cache(name=None, project=None, user=None)[source]
Update items by certain name within a project by calling implemented functions in project app plugins.
- Parameters
name – Item name to limit update to (string, optional)
project – Project object to limit update to (optional)
user – User object to denote user triggering the update (optional)
Models
- class sodarcache.models.BaseCacheItem(*args, **kwargs)[source]
Abstract class representing a cached item
- app_name
App name
- date_modified
DateTime of the update
- name
Identifier for the item given by the data setting app
- project
Project in which the item belongs (optional)
- sodar_uuid
UUID for the item
- user
User who updated the item (optional)