You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It uses `redis <http://redis.io/>`_ as backend for ORM cache and redis or
8
8
filesystem for simple time-invalidated one.
@@ -15,15 +15,18 @@ And there is more to it:
15
15
- dog-pile prevention mechanism
16
16
- a couple of hacks to make django faster
17
17
18
+
.. contents:: Contents
19
+
:local:
20
+
:backlinks: top
18
21
19
22
Requirements
20
-
------------
23
+
++++++++++++
21
24
22
25
Python 3.5+, Django 2.1+ and Redis 4.0+.
23
26
24
27
25
28
Installation
26
-
------------
29
+
++++++++++++
27
30
28
31
Using pip:
29
32
@@ -36,7 +39,7 @@ Using pip:
36
39
37
40
38
41
Setup
39
-
-----
42
+
+++++
40
43
41
44
Add ``cacheops`` to your ``INSTALLED_APPS``.
42
45
@@ -157,7 +160,7 @@ There is also a possibility to make all cacheops methods and decorators no-op, e
157
160
158
161
159
162
Usage
160
-
-----
163
+
+++++
161
164
162
165
|**Automatic caching**
163
166
@@ -289,7 +292,7 @@ Class based views can also be cached:
289
292
290
293
291
294
Invalidation
292
-
------------
295
+
++++++++++++
293
296
294
297
Cacheops uses both time and event-driven invalidation. The event-driven one
295
298
listens on model signals and invalidates appropriate caches on ``Model.save()``, ``.delete()``
@@ -373,6 +376,9 @@ In the case you actually want to perform the latter cacheops provides a shortcut
373
376
374
377
Note that all the updated objects are fetched twice, prior and post the update.
375
378
379
+
Components
380
+
++++++++++
381
+
376
382
377
383
Simple time-invalidated cache
378
384
-----------------------------
@@ -584,6 +590,9 @@ or
584
590
Tags work the same way as corresponding decorators.
585
591
586
592
593
+
Special topics
594
+
++++++++++++++
595
+
587
596
Transactions
588
597
------------
589
598
@@ -728,11 +737,10 @@ Cache invalidation signal is emitted after object, model or global invalidation
728
737
Memory usage cleanup
729
738
--------------------
730
739
731
-
In some cases, cacheops may leave some conjunction keys of expired cache keys in redis without being able
732
-
to invalidate them. Cacheops ships with a ``cacheops.reap_conjs`` function that can clean up these keys,
733
-
ignoring conjunction sets with some reasonable size.
740
+
In some cases, cacheops may leave some conjunction keys of expired cache keys in redis without being able to invalidate them. Those will still expire with age, but in the meantime may cause issues like slow invalidation (even "BUSY Redis ...") and extra memory usage. To prevent that it is advised to not cache complex queries, see `Perfomance tips <#performance-tips>`_, 5.
734
741
735
-
It can be called using the ``reapconjs`` management command::
742
+
Cacheops ships with a ``cacheops.reap_conjs`` function that can clean up these keys,
743
+
ignoring conjunction sets with some reasonable size. It can be called using the ``reapconjs`` management command::
736
744
737
745
./manage.py reapconjs --chunk-size=100 --min-conj-set-size=10000 # with custom values
738
746
./manage.py reapconjs # with default values (chunks=1000, min size=1000)
@@ -751,6 +759,9 @@ The command is a small wrapper that calls a function with the main logic. You ca
751
759
)
752
760
753
761
762
+
Troubleshooting
763
+
+++++++++++++++
764
+
754
765
CAVEATS
755
766
-------
756
767
@@ -818,7 +829,7 @@ Here is how you do that. I suppose you have some application code causing it.
818
829
819
830
820
831
TODO
821
-
----
832
+
++++
822
833
823
834
- faster .get() handling for simple cases such as get by pk/id, with simple key calculation
0 commit comments