Django redis backend
Project description
Django-redisdb is Redis backend for Django that allows using Redis as a cache and as a database at the same time. Django-redisdb provides backends for master/master and sharded configuration.
Installation
pip install django-redisdb
Quick usage guide
In settings.py:
CACHES = {
'redis_ring': {
'BACKEND': 'redisdb.backends.RedisRing', # sharding backend
'DB': 0,
'LOCATION': [
'localhost:6379',
'localhost:6380',
],
},
'redis_copy': {
'BACKEND': 'redisdb.backends.RedisCopy', # copying backend
'DB': 0,
'LOCATION': [
'localhost:6379',
'localhost:6380',
],
}
}
Usage:
>>> from django.core.cache import caches
>>> caches['redis_ring'].set('one_key', 123) # set key1 only on on server
[True]
>>> caches['redis_copy'].set('other_key', 234) # set key2 on all servers
[True, True]
With RedisRing value is set only on one node. With RedisCopy it’s set on all nodes (two nodes in examle above).
Redis is much more powerfull then simple cache. It should be seen as a specialized database. With django-redisdb you can use all its power. For example you can use redis’ sorted sets:
>>> caches['redis_copy'].zadd('myzset', 1, 'one')
[0, 1]
>>> caches['redis_copy'].zadd('myzset', 2, 'two')
[0, 1]
>>> caches['redis_copy'].zadd('myzset', 3, 'three')
[0, 1]
>>> caches['redis_copy'].zrange('myzset', 0, -1)
['one', 'two', 'three']
>>> caches['redis_copy'].zrange('myzset', 0, -1, withscores=True)
[('one', 1.0), ('two', 2.0), ('three', 3.0)]
Supported Django versions
django-redisdb runs on Django 1.2 to Django 1.8
Documentation
Full documentation is available at http://django-redisdb.readthedocs.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-redisdb-0.2.1.tar.gz
.
File metadata
- Download URL: django-redisdb-0.2.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c162a391c61f2598ca9fd7e2a0a8276c0156e2ea92ea35626d4da36e90349310 |
|
MD5 | 89162c3d955affcff417c3f45934a156 |
|
BLAKE2b-256 | 702fb248e831e86147a7571ad98a87f746a7e98b6b5bd0b80d3afbee30cb26cb |
File details
Details for the file django_redisdb-0.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_redisdb-0.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96097c7ca39b3168ae52ed32c8c96c89d37e6718a356cf53345aff5932373092 |
|
MD5 | 54af86fdd36a064414eeb4a14f9630cb |
|
BLAKE2b-256 | 02c6cee8213e859d0eef88515565508dccb2ecc1ff99eb34fa9262aed53f82ea |