a simple tool for making caching functions, methods, and class methods a little bit easier.
Project description
django-cache-helper
Overview
django-cache-helper is a simple tool for making caching functions, methods, and class methods a little bit easier. 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.
In order to cache and invalidate a function/method/class_method/static_method:
Support
Python |
---|
3.7, 3.8, 3.9, 3.10 |
How to Cache
# Caching a function
@cached(60*60) # 60 Minutes
def foo(bar):
return bar
class Incrementer:
@cached_instance_method(60 * 60)
def instance_increment_by(self, num):
return num
@classmethod
@cached_class_method(60 * 60)
def class_increment_by(cls, num):
return num
@staticmethod
@cached(60 * 60)
def get_datetime():
return datetime.utcnow()
How to invalidate a cache
foo(1)
foo.invalidate(1)
Incrementer.instance_increment_by(1)
Incrementer.instance_increment_by.invalidate(1)
Incrementer.class_increment_by(1)
Incrementer.class_increment_by.invalidate(1)
Incrementer.get_datetime()
Incrementer.get_datetime.invalidate()
Contributors ✨
Thanks goes to these wonderful people.
Kevin Fox |
Tom Jakeway |
Ara Anjargolian |
Hyuckin David Lim |
James |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django_cache_helper-1.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ea9d8453676304eeec4ed1bacb59a8ce4497e7b7f5fec39e8fa8473a822a8bd |
|
MD5 | 682e1b33bb97e6ccf42107cff4cf47fa |
|
BLAKE2b-256 | c1819062bb17318cd720ea5f6dba83bffa3b15b41e7946c63da04ca01d83934a |
Close
Hashes for django_cache_helper-1.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fea55e87d6200c05b3845dd62b8fc6396fce082ad537a34d64e3e1def2ad394 |
|
MD5 | 34acee73d1fff01377a70087b7085d2c |
|
BLAKE2b-256 | 7b2b65f406096cd52ad6def90bb2b2bb30b26fe4dfe58eb9b919ae68b32b531e |