
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
django-request-cache
Advanced tools
.. image:: https://badge.fury.io/py/django-request-cache.svg :target: https://badge.fury.io/py/django-request-cache .. image:: https://github.com/anexia/django-request-cache/actions/workflows/test.yml/badge.svg?branch=main :target: https://github.com/anexia/django-request-cache/actions/workflows/test.yml .. image:: https://codecov.io/gh/anexia/django-request-cache/branch/main/graph/badge.svg :target: https://codecov.io/gh/anexia/django-request-cache
Django Request Cache provides a cache for each request (within your Django Request/Response cycle).
pip install
.. code-block:: bash
pip install django-request-cache
2. Add UserForeignKeyMiddleware
and RequestCacheMiddleware
to your MIDDLEWARE
settings like this:
.. code-block:: python
MIDDLEWARE = (
...
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
'django_userforeignkey.middleware.UserForeignKeyMiddleware',
'django_request_cache.middleware.RequestCacheMiddleware',
)
or if you are still using the an older Django version (e.g., Django 1.8) with MIDDLEWARE_CLASSES
:
.. code-block:: python
MIDDLEWARE_CLASSES = (
...
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
'django_userforeignkey.middleware.UserForeignKeyMiddleware',
'django_request_cache.middleware.RequestCacheMiddleware',
)
3. Use the per-request cache as a decorator
.. code-block:: python
from django_request_cache import cache_for_request
@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 middleware.py
) are from a source code snippet on StackOverflow
https://stackoverflow.com/questions/3151469/per-request-cache-in-django/37015573#37015573
created by coredumperror https://stackoverflow.com/users/464318/coredumperror
Original Question was posted by https://stackoverflow.com/users/7679/chase-seibert
at https://stackoverflow.com/questions/3151469/per-request-cache-in-django
copied on 2017-Dec-20
FAQs
A simple Django app that provides a per-request cache.
We found that django-request-cache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.