| 1 |
How django-cachalot works |
| 2 |
------------------------- |
| 3 |
|
| 4 |
.. note:: |
| 5 |
If you don’t understand, you can pretend it’s magic. |
| 6 |
|
| 7 |
Reverse engineering |
| 8 |
................... |
| 9 |
|
| 10 |
It’s a lot of Django reverse engineering combined with a strong test suite. |
| 11 |
Such a test suite is crucial for a reverse engineering project. |
| 12 |
If some important part of Django changes and breaks the expected behaviour, |
| 13 |
you can be sure that the test suite will fail. |
| 14 |
|
| 15 |
Monkey patching |
| 16 |
............... |
| 17 |
|
| 18 |
Django-cachalot modifies Django in place during execution to add a caching tool |
| 19 |
just before SQL queries are executed. |
| 20 |
When a SQL query reads data, we save the result in cache. If that same query is |
| 21 |
executed later, we fetch that result from cache. |
| 22 |
When we detect ``INSERT``, ``UPDATE`` or ``DELETE``, we know which tables are |
| 23 |
modified. All the previous cached queries can therefore be safely invalidated. |