Skip to main content

Django redis backend

Project description

Wheel Status Latest Version License

Goal

Provide Redis backends for Django that faciliates using multiple Redis servers in the same time like if they were in master/master or sharded configuration.

Installation

Install requirements:

pip install -r requirements.txt

Install Redisdb:

pip install django-redisdb

or current development version:

pip install hg+https:://bitbucket.org/kidosoft/django-redisdb

Configuration

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',
        ]
    }
}

Redis is configured as cache backend although it should be treat as specialized database. There are two backends:

Usage

After configuration access to Redis is done like to any other Django cache:

from django.core.cache import caches
caches['redis_ring'].set('key1', 1)  # set key1 only on on server
caches['redis_copy'].set('key2', 2)  # set key2 on all servers
result_list = caches['redis_copy'].zrange('key3', 1, 10)  # redis only command

Caveats

RedisCopy can save data to many nodes. Each of this nodes can return different result on save. For that reason commands that save data to nodes returns list of results from each node. E.g. with two nodes set for redis_copy:

>>> print caches['redis_copy'].set('key1', 2)
[True, True]

Supported Django versions

Tested with:

  • Django 1.2.7 on python2.7

  • Django 1.3.7 on python2.7

  • Django 1.4.16 on python2.7

  • Django 1.5.11 on python2.7, python3.2, python3.3, python3.4

  • Django 1.6.8 on python2.7, python3.2, python3.3, python3.4

  • Django 1.7.1 on python2.7, python3.2, python3.3, python3.4

Documentation

http://kidosoft.pl/docs/django-redisdb/

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

django-redisdb-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

django_redisdb-0.1.0-py2.py3-none-any.whl (8.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-redisdb-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django-redisdb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2c059d57814acdaae56523c4e21079322d69722db41edf9fd41e060e42907ed2
MD5 048cbbc3b321b3e1673b0dce2a7b5fd9
BLAKE2b-256 f6b9a7975e76ca8b8ec86d536544c9c3f7927e3b0536e480bcb3265ab3d866cc

See more details on using hashes here.

File details

Details for the file django_redisdb-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_redisdb-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0e86595408a806cae946d77f3b811e7eec8570f09f0f6134e92308a14adb0556
MD5 90379ad6c51d0b49a9e1f65cdf0e97d5
BLAKE2b-256 ed213dd8d7fbc0d7d6eea939a317973306459fda2a7a852da2f4963abb44aa27

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page