Skip to main content

A simple Django app that provides a per-request cache.

Project description

Django Request Cache provides a cache for each request (within your Django Request/Response cycle).

Quick start

  1. Download and install using pip install
pip install django-request-cache
  1. Add UserForeignKeyMiddleware and RequestCacheMiddleware to your MIDDLEWARE settings like this:

or if you are still using the an older Django version (e.g., Django 1.8) with MIDDLEWARE_CLASSES:

  1. Use the per-request cache as a decorator
from django_request_cache import cache_for_request

def do_some_complex_calculation(a, b, c):
    print("Calculating... please wait")
    return a * b * c

Try it out by executing do_some_complex_calculation multiple times within your request


RequestCache and RequestCacheMiddleware (see are from a source code snippet on StackOverflow created by coredumperror Original Question was posted by at copied on 2017-Dec-20

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-request-cache-1.2.tar.gz (4.5 kB view hashes)

Uploaded source

Built Distribution

django_request_cache-1.2-py2.py3-none-any.whl (4.7 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page