Skip to main content

Django redis backend

Project description

Wheel Status Latest Version License Build status Coverage Documetation

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/en/latest/index.html

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.2.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

django_redisdb-0.2.0-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for django-redisdb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e33a22cf285f817b7f88e1178dbffd352f40bf5d222f953757f9d7bd8d51ae0d
MD5 3721e1f202aedd0aebaa0524231e3dcf
BLAKE2b-256 ae6b3f16e9cbcd9c16e29797eca21bb098729de45e0ba752671edb1b26a4df1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_redisdb-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 105106282b840ec24eefce4ef72161b832331f4d8d91218c2c905416df9cd50f
MD5 c270fe6608fb58df7a68e2dc73836c20
BLAKE2b-256 91e344818b6ab9c6c0a4bbc4069fad1152b9af61584be3427bc5ad7aed8fdb75

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