A Django cache backend with fallthrough
Project description
# django-fallthrough-cache
An implementation of Django's cache backend interface that allows you to put a
fast cache (e.g. `LocMemCache`) in front of a slower one (e.g. `PyLibMCCache`).
## Usage
The configuration below sets up 3 caches: 'locmem', 'memcache', and
'fallthrough'. The fallthrough cache will look up values in the local memory
cache, and on cache misses it will fall through to memcache.
```python
CACHES = {
'locmem': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'local-memory',
'TIMEOUT': 60,
'VERSION': 1
},
'memcache': {
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': os.environ['MEMCACHE_HOST'],
'TIMEOUT': None,
'OPTIONS': {
'connect_timeout': 1000,
'receive_timeout': 1000000,
'send_timeout': 1000000,
'dead_timeout': 5,
},
'VERSION': 1
},
'fallthrough': {
'BACKEND': 'fallthrough_cache.FallthroughCache',
'OPTIONS': {
'cache_names': ['locmem', 'memcache']
}
}
}
```
An implementation of Django's cache backend interface that allows you to put a
fast cache (e.g. `LocMemCache`) in front of a slower one (e.g. `PyLibMCCache`).
## Usage
The configuration below sets up 3 caches: 'locmem', 'memcache', and
'fallthrough'. The fallthrough cache will look up values in the local memory
cache, and on cache misses it will fall through to memcache.
```python
CACHES = {
'locmem': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'local-memory',
'TIMEOUT': 60,
'VERSION': 1
},
'memcache': {
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': os.environ['MEMCACHE_HOST'],
'TIMEOUT': None,
'OPTIONS': {
'connect_timeout': 1000,
'receive_timeout': 1000000,
'send_timeout': 1000000,
'dead_timeout': 5,
},
'VERSION': 1
},
'fallthrough': {
'BACKEND': 'fallthrough_cache.FallthroughCache',
'OPTIONS': {
'cache_names': ['locmem', 'memcache']
}
}
}
```
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
File details
Details for the file django-fallthrough-cache-0.1.0.tar.gz.
File metadata
- Download URL: django-fallthrough-cache-0.1.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc99b79482de1c6064a80d1a9f7cf41a8fb1becc557f5ea1fb73f28b07a4ff16
|
|
| MD5 |
d91ba61e744b42dd8c2832537bc66361
|
|
| BLAKE2b-256 |
0a3fba79e606ffaab157469be0118556d3f2534a61b33b55aee6649249410983
|