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
File details
Details for the file django-cache-helper-1.0.4.tar.gz
.
File metadata
- Download URL: django-cache-helper-1.0.4.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22bd71edaf66189e4a5d201841811f77f2cc4b7d1dfc76d938ca72763be00c25 |
|
MD5 | 3451023de9ad395926ed9542183168da |
|
BLAKE2b-256 | 016758cab42bcd0ccd37e118646dcfcf1084ea113b62c3e19104751bf39e8cce |
File details
Details for the file django_cache_helper-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: django_cache_helper-1.0.4-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 463f399a473fc9bef63fc2d0644c1ee34024d10ca1decc07eaf0ef21d1d63cd7 |
|
MD5 | d1fd9a594a46b50aca62f77744695f9b |
|
BLAKE2b-256 | f528da7b4fe8fb1fcd44a65efcf830c0599ebda306ffa715dc2c70ed4b3d2a72 |