Skip to main content

Redis-Sentinel integration for Flask

Project description

# Flask-Redis-Sentinel


Flask-Redis-Sentinel provides support for connecting to Redis using Sentinel and also supports connecting to Redis
without it.

* Supports Python 2.7 and 3.3+
* Licensed using Apache License 2.0

## Basic usage

from flask.ext.redis_sentinel import SentinelExtension

redis_sentinel = SentinelExtension()
redis_connection = redis_sentinel.default_connection

# Later when you create application
app = Flask(...)

You can configure Redis connection parameters using `REDIS_URL` Flask configuration variable with `redis+sentinel`
URL scheme:


The extension also supports URL schemes as supported by redis-py for connecting to an instance directly without Sentinel:


Flask-And-Redis style config variables are also supported for easier migration, but the extension will
log a `DeprecationWarning`:

REDIS_HOST = 'localhost'

In case both `REDIS_URL` and other variables are present, the URL is used.

## Creating multiple connection pools using a single Sentinel cluster

from flask.ext.redis_sentinel import SentinelExtension

redis_sentinel = SentinelExtension()
master1 = redis_sentinel.master_for('service1')
master2 = redis_sentinel.master_for('service2')
slave1 = redis_sentinel.master_for('service1')

## Accessing redis-py's Sentinel instance

from flask.ext.redis_sentinel import SentinelExtension
from flask import jsonify, Flask

app = Flask('test')

redis_sentinel = SentinelExtension(app=app)

def index():
slaves = redis_sentinel.sentinel.discover_slaves('service1')
return jsonify(slaves=slaves)


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Flask-Redis-Sentinel, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size Flask_Redis_Sentinel-0.1.0-py2.py3-none-any.whl (5.6 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size Flask-Redis-Sentinel-0.1.0.tar.gz (8.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page