API¶
Use these tools if the automatic behaviour of django-cachalot is not enough. See Raw SQL queries.
- cachalot.api.invalidate_tables(tables, cache_alias=None, db_alias=None)[source]¶
Clears what was cached by django-cachalot implying one or more SQL tables from tables.
If cache_alias is specified, it only clears the SQL queries stored on this cache, otherwise queries from all caches are cleared.
If db_alias is specified, it only clears the SQL queries executed on this database, otherwise queries from all databases are cleared.
Parameters: - tables (iterable of strings) – SQL tables names
- cache_alias (string or NoneType) – Alias from the Django CACHES setting
- db_alias (string or NoneType) – Alias from the Django DATABASES setting
Returns: Nothing
Return type: NoneType
- cachalot.api.invalidate_models(models, cache_alias=None, db_alias=None)[source]¶
Shortcut for invalidate_tables where you can specify Django models instead of SQL table names.
Parameters: - models (iterable of django.db.models.Model subclasses) – Django models
- cache_alias (string or NoneType) – Alias from the Django CACHES setting
- db_alias (string or NoneType) – Alias from the Django DATABASES setting
Returns: Nothing
Return type: NoneType
- cachalot.api.invalidate_all(cache_alias=None, db_alias=None)[source]¶
Clears everything that was cached by django-cachalot.
If cache_alias is specified, it only clears the SQL queries stored on this cache, otherwise queries from all caches are cleared.
If db_alias is specified, it only clears the SQL queries executed on this database, otherwise queries from all databases are cleared.
Parameters: - cache_alias (string or NoneType) – Alias from the Django CACHES setting
- db_alias – Alias from the Django DATABASES setting
Returns: Nothing
Return type: NoneType