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
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
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.5.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

django_cache_helper-1.0.5-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file django_cache_helper-1.0.5.tar.gz.

File metadata

  • Download URL: django_cache_helper-1.0.5.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.9

File hashes

Hashes for django_cache_helper-1.0.5.tar.gz
Algorithm Hash digest
SHA256 f2b8a06b234a76bf68f1e6493d34ef64046c191dcec9a8dc65452acb9a3c9883
MD5 1cd6dfb2a29f9af8153168b3a10dad44
BLAKE2b-256 650b6dd5e480d0349428662a9dbbd9342e2d3cffc9625b74f4a28befad0eaa5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_cache_helper-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ca266f76c08325c438cb688c42c5ef7f0f74237a3b84e045922eef0e620f72f3
MD5 ab47aeb957cdb72f8d485d2b802b496b
BLAKE2b-256 8f2cbfbf6c8c3f33ae97443660e7d4f1226abf489a2e4adf5bc01808b7d737a6

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