Skip to main content
https://img.shields.io/travis/LabD/django-cache-results/master.svg?branch=master https://img.shields.io/pypi/v/LabD.svg https://img.shields.io/pypi/l/LabD.svg https://img.shields.io/codecov/c/github/LabD/django-cache-results/master.svg

django-cache-results

A microlibrary to ease your caching code.

Usage:

def key_function(arg1, arg2):
    return f"prefix.{arg1}.{arg2}"

@cache_results(key_function=key_function)
def some_function(arg1, arg2):
    return "COMPLEX DATA"

Normal usage:

value = some_function(1, 2)

Skipping the cache:

value = some_function.bypass_cache(1, 2)

Updating the cache:

value = some_function.refresh_cache(1, 2)

Fetch the key for manual action:

cache_key = some_function.cache_key(1, 2)

Installation

Install the module from PyPI:

pip install django-cache-results

And use it in your project:

from cache_results import cache_results

Contributing

Was there something you missed, or didn’t like about this module? Send us a pull request!

Release history Release notifications | RSS feed

This release

0.9 This release

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page