A redis-backed autocompleter for Django projects.
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 | Django |
---|---|
3.7, 3.8, 3.9, 3.10 | 3.2 |
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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b350738ffda1c44b8517720d83d49092e2ac7d927afcc947f36b93d3a3acd446 |
|
MD5 | eb7327a9efc0dad6f5bdc28835a82c49 |
|
BLAKE2b-256 | 56df37813eb0aa38a412a5da153779458a6f25ac03909347d335cc9156f24318 |
Close
Hashes for django_cache_helper-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da6fc91c04dd5c3f747096aa99dbe7768c1776cebbbe44f9b378787ac7761b70 |
|
MD5 | 986b41712a397a30fb798370cc84aaec |
|
BLAKE2b-256 | 31399681ff8ed40f52b1943a7d66e1ecde3d601832755b3a313d8d6b7ba4fa02 |