Skip to content

Commit a735271

Browse files
committed
Updaed readme.md
1 parent 7033d6b commit a735271

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ django-cache-helper
1010
django-cache-helper is a simple tool for making caching functions, methods, and class methods a little bit easier.
1111
It is largely based off of django-cache-utils, however, since cache-utils did not support caching model methods by instance and carried other features I didn't need, django-cache-helper was created.
1212

13-
In order to cache a function/method/class_method/static_method:
13+
In order to cache and invalidate a function/method/class_method/static_method:
14+
15+
## Support
16+
17+
| Python | Django |
18+
|--------|--------|
19+
| 3.7, 3.8, 3.9, 3.10 | 3.2 |
20+
21+
22+
#### How to Cache
1423

1524
```python
1625
# Caching a function
@@ -31,13 +40,27 @@ class Incrementer:
3140

3241
@staticmethod
3342
@cached(60 * 60)
34-
def get_datetime(num):
35-
return num
43+
def get_datetime():
44+
return datetime.utcnow()
45+
```
46+
47+
#### How to invalidate a cache
48+
49+
```python
50+
51+
foo(1)
52+
foo.invalidate(1)
53+
54+
Incrementer.instance_increment_by(1)
55+
Incrementer.instance_increment_by.invalidate(1)
56+
57+
Incrementer.class_increment_by(1)
58+
Incrementer.class_increment_by.invalidate(1)
59+
60+
Incrementer.get_datetime()
61+
Incrementer.get_datetime.invalidate()
3662
```
37-
## Support
38-
**Python:** 3.7, 3.8, 3.9, 3.10
3963

40-
**Django:** 3.2
4164

4265
## Contributors ✨
4366

0 commit comments

Comments
 (0)