Skip to content

Commit 5aaeae9

Browse files
committed
Update README
- add a link to a post explaining internals - add TOC - explain about conj keys, slow invalidation, BUSY Redis more Closes #444.
1 parent c450ae1 commit 5aaeae9

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

README.rst

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Cacheops |Build Status|
22
========
33

4-
A slick app that supports automatic or manual queryset caching and automatic
5-
granular event-driven invalidation.
4+
A slick app that supports automatic or manual queryset caching and `automatic
5+
granular event-driven invalidation <http://suor.github.io/blog/2014/03/09/on-orm-cache-invalidation/>`_.
66

77
It uses `redis <http://redis.io/>`_ as backend for ORM cache and redis or
88
filesystem for simple time-invalidated one.
@@ -15,15 +15,18 @@ And there is more to it:
1515
- dog-pile prevention mechanism
1616
- a couple of hacks to make django faster
1717

18+
.. contents:: Contents
19+
:local:
20+
:backlinks: top
1821

1922
Requirements
20-
------------
23+
++++++++++++
2124

2225
Python 3.5+, Django 2.1+ and Redis 4.0+.
2326

2427

2528
Installation
26-
------------
29+
++++++++++++
2730

2831
Using pip:
2932

@@ -36,7 +39,7 @@ Using pip:
3639
3740
3841
Setup
39-
-----
42+
+++++
4043

4144
Add ``cacheops`` to your ``INSTALLED_APPS``.
4245

@@ -157,7 +160,7 @@ There is also a possibility to make all cacheops methods and decorators no-op, e
157160
158161
159162
Usage
160-
-----
163+
+++++
161164

162165
| **Automatic caching**
163166
@@ -289,7 +292,7 @@ Class based views can also be cached:
289292
290293
291294
Invalidation
292-
------------
295+
++++++++++++
293296

294297
Cacheops uses both time and event-driven invalidation. The event-driven one
295298
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
373376
374377
Note that all the updated objects are fetched twice, prior and post the update.
375378

379+
Components
380+
++++++++++
381+
376382

377383
Simple time-invalidated cache
378384
-----------------------------
@@ -584,6 +590,9 @@ or
584590
Tags work the same way as corresponding decorators.
585591

586592

593+
Special topics
594+
++++++++++++++
595+
587596
Transactions
588597
------------
589598

@@ -728,11 +737,10 @@ Cache invalidation signal is emitted after object, model or global invalidation
728737
Memory usage cleanup
729738
--------------------
730739

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.
734741

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::
736744

737745
./manage.py reapconjs --chunk-size=100 --min-conj-set-size=10000 # with custom values
738746
./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
751759
)
752760
753761
762+
Troubleshooting
763+
+++++++++++++++
764+
754765
CAVEATS
755766
-------
756767

@@ -818,7 +829,7 @@ Here is how you do that. I suppose you have some application code causing it.
818829

819830

820831
TODO
821-
----
832+
++++
822833

823834
- faster .get() handling for simple cases such as get by pk/id, with simple key calculation
824835
- integrate previous one with prefetch_related()

0 commit comments

Comments
 (0)