Skip to main content

a simple tool for making caching functions, methods, and class methods a little bit easier.

Project description

django-cache-helper

  PyPI Test Suite Coverage Status

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
Kevin Fox
Tom Jakeway
Tom Jakeway
Ara Anjargolian
Ara Anjargolian
Hyuckin David Lim
Hyuckin David Lim
James
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

django-cache-helper-1.0.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

django_cache_helper-1.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file django-cache-helper-1.0.2.tar.gz.

File metadata

  • Download URL: django-cache-helper-1.0.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for django-cache-helper-1.0.2.tar.gz
Algorithm Hash digest
SHA256 24f8ad99cf30133efbb1f826cd842b66f223b1e231bf750a71abf2be4e0021b6
MD5 c829d48db14aec0b38fb65edcd08248b
BLAKE2b-256 3bffd6ea50eaf6a2ed1d56c40f150c485469bf841dfd0b8fa02c50a6569c575f

See more details on using hashes here.

File details

Details for the file django_cache_helper-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_cache_helper-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5348a1316cd910570d3d977b38a652636ee6149220fa67ec628f3251d0c01144
MD5 8b448443c1a593132fe0b7838e3d3dd4
BLAKE2b-256 e97b65184160f9bddbdadd755795a9f47b658afb033bcdf2d7ed6fa2a6746011

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page