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
Copy file name to clipboardExpand all lines: README.rst
+8-2
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,10 @@
1
+
==================================
1
2
Django Fragment Cache Invalidation
2
3
==================================
3
4
4
5
Fragment cache invalidation by using a per model version token to prefix the cache keys. The version token can either be an internal memcached counter or a timestamped attribute from the model, such as `updated_at`.
5
6
6
-
installation
7
+
Installation
7
8
------------
8
9
9
10
Install with `pip` or with `python setup.py install` and add 'cachesweeper' to your `settings.INSTALLED_APPS`
@@ -16,7 +17,9 @@ An example setup; an article has many comments, each comment is cached, a single
16
17
17
18
**Template fragment caching**
18
19
19
-
`{% cachesweeper %}` takes a Django ORM model as its first argument, the expiry time as its second and any following arguments are used to construct the rest of the cache key.
20
+
`{% cachesweeper %}` takes a Django ORM model as its first argument, the expiry time as its second and any following arguments are used to construct the rest of the cache key
21
+
22
+
::
20
23
21
24
{% load markup %}
22
25
{% load cachesweeper_tags %}
@@ -33,6 +36,8 @@ An example setup; an article has many comments, each comment is cached, a single
33
36
**Invalidating the fragment when the model changes**
34
37
35
38
On a post_save invalidate the cache for the given model. There are two options, either have Memcached keep an internal version counter for each model or using the keyword `using` as a means of versioning the cache.
39
+
40
+
::
36
41
37
42
from cachesweeper.utils import invalidate_cache_for
38
43
@@ -50,3 +55,4 @@ On a post_save invalidate the cache for the given model. There are two options,
0 commit comments