8 Django packages that implement caching
- Mar 19, 2022
No effort, no worry, maximum performance.
Automatic caching and invalidation for Django models through the ORM.
git clone git://github.com/django-cache-machine/django-cache-machine.git cd django-cache-machine pip install -r requirements/py3.txt # or py2.txt for Python 2 python run_tests.py
A slick ORM cache with automatic granular event-driven invalidation.
Using pip:
$ pip install django-cacheops
# Or from github directly
$ pip install git+https://github.com/Suor/django-cacheops.git@master
caching django orm python
An implementation of memoization technique for Django
An ORM cache for Django.
A Redis cache backend for django
# When using TCP connections CACHES = { 'default': { 'BACKEND': 'redis_cache.RedisCache', 'LOCATION': [ '<host>:<port>', '<host>:<port>', '<host>:<port>', ], 'OPTIONS': { 'DB': 1, 'PASSWORD': 'yadayada', 'PARSER_CLASS': 'redis.connection.HiredisParser', 'CONNECTION_POOL_CLASS': 'redis.BlockingConnectionPool', 'CONNECTION_POOL_CLASS_KWARGS': { 'max_connections': 50, 'timeout': 20, }, 'MAX_CONNECTIONS': 1000, 'PICKLE_VERSION': -1, }, }, } # When using unix domain sockets # Note: ``LOCATION`` needs to be the same as the ``unixsocket`` setting # in your redis.conf CACHES = { 'default': { 'BACKEND': 'redis_cache.RedisCache', 'LOCATION': '/path/to/socket/file', 'OPTIONS': { 'DB': 1, 'PASSWORD': 'yadayada', 'PARSER_CLASS': 'redis.connection.HiredisParser', 'PICKLE_VERSION': 2, }, }, } # For Master-Slave Setup, specify the host:port of the master # redis-server instance. CACHES = { 'default': { 'BACKEND': 'redis_cache.RedisCache', 'LOCATION': [ '<host>:<port>', '<host>:<port>', '<host>:<port>', ], 'OPTIONS': { 'DB': 1, 'PASSWORD': 'yadayada', 'PARSER_CLASS': 'redis.connection.HiredisParser', 'PICKLE_VERSION': 2, 'MASTER_CACHE': '<master host>:<master port>', }, }, }
johnny cache django caching framework
Python disk-backed cache (Django-compatible). Faster than Redis and Memcached. Pure-Python.
Features
- Pure-Python
- Fully Documented
- Benchmark comparisons (alternatives, Django cache backends)
- 100% test coverage
- Hours of stress testing
- Performance matters
- Django compatible API
- Thread-safe and process-safe
- Supports multiple eviction policies (LRU and LFU included)
- Keys support "tag" metadata and eviction
- Developed on Python 3.10
- Tested on CPython 3.6, 3.7, 3.8, 3.9, 3.10
- Tested on Linux, Mac OS X, and Windows
- Tested using GitHub Actions
In [1]: import pylibmc In [2]: client = pylibmc.Client(['127.0.0.1'], binary=True) In [3]: client[b'key'] = b'value' In [4]: %timeit client[b'key'] 10000 loops, best of 3: 25.4 µs per loop In [5]: import diskcache as dc In [6]: cache = dc.Cache('tmp') In [7]: cache[b'key'] = b'value' In [8]: %timeit cache[b'key'] 100000 loops, best of 3: 11.8 µs per loopcache filesystem key-value-store persistence python