Django Cachalot
Caches your Django ORM queries and automatically invalidates them.
Quickstart
Cachalot officially supports Python 3.6-3.9 and Django 2.2 and 3.1-3.2 with the databases PostgreSQL, SQLite, and MySQL.
Note: an upper limit on Django version is set for your safety. Please do not ignore it.
Usage
pip install django-cachalot
- Add
'cachalot',
to yourINSTALLED_APPS
- If you use multiple servers with a common cache server, double check their clock synchronisation
- If you modify data outside Django – typically after restoring a SQL database –, use the manage.py command
- Be aware of the few other limits
- If you use django-debug-toolbar, you can add
'cachalot.panels.CachalotPanel',
to yourDEBUG_TOOLBAR_PANELS
- Enjoy!
Hacking
To start developing, install the requirements and run the tests via tox.
Make sure you have the following services:
- Memcached
- Redis
- PostgreSQL
- MySQL
For setup:
- Install:
pip install -r requirements/hacking.txt
- For PostgreSQL:
CREATE ROLE cachalot LOGIN SUPERUSER;
- Run:
tox --current-env
to run the test suite on your current Python version. - You can also run specific databases and Django versions:
tox -e py38-django3.1-postgresql-redis
Benchmark
Currently, benchmarks are supported on Linux and Mac/Darwin. You will need a database called "cachalot" on MySQL and PostgreSQL. Additionally, on PostgreSQL, you will need to create a role called "cachalot." You can also run the benchmark, and it'll raise errors with specific instructions for how to fix it.
- Install:
pip install -r requirements/benchmark.txt
- Run:
python benchmark.py
The output will be in benchmark/TODAY'S_DATE/
TODO Create Docker-compose file to allow for easier running of data.