Skip to content

max-k/flask-multi-redis

Repository files navigation

Flask-Multi-Redis

CI Status

Travis CI Status

Codecov Coverage Status

Coveralls Coverage Status

Codacy Coverage Status

Codacy Code Grade

Landscape Code Health

Code Climate

Code Climate Coverage

PyPI Status

Pypi Version

Pypi Status

Python Implementation

Python Versions

License aGPLv3+


Adds Redis support to Flask with fail-over or aggregation capabilities.

Mostly inspired by these projects :

Built on top of redis-py.

Contributors

Description

Flask-Multi-Redis allows you to easily access multiple Redis servers from Flask applications. It supports SSL connections and password authentication. It's not intended to implement all Redis commands but gives you the hability to make multi-threaded parallel queries to multiple Redis servers without the need to deploy a Redis cluster.

Installation

pip install flask-multi-redis

Configuration

Enable Flask-Multi-Redis in your application :

from flask import Flask
from flask.ext.redis import FlaskRedis

app = Flask(__name__)
redis_store = FlaskRedis(app)

Flask-Multi-Redis provide a simple flexible configuration handling. It reads its configuration from your Flask app.config dictionnary.

Default configuration for all servers :

app.config['REDIS_DEFAULT_PORT'] = 6379
app.config['REDIS_DEFAULT_DB'] = 0
app.config['REDIS_DEFAULT_PASSWORD'] = None
app.config['REDIS_DEFAULT_SOCKET_TIMEOUT'] = 5
app.config['REDIS_DEFAULT_SSL'] = None

Usage

FlaskMultiRedis proxies attribute access to an underlying Redis connection. So treat it as if it were a regular Redis instance.

@app.route('/')
def index():
    return redis_store.get('potato', 'Not Set')

Protip: The redis-py package currently holds the 'redis' namespace, so if you are looking to make use of it, your Redis object shouldn't be named 'redis'.

For detailed instructions regarding the usage of the client, check the redis-py documentation.

Advanced features, such as Lua scripting, pipelines and callbacks are detailed within the projects README.

Contribute

About

MultiThreaded and MultiServers Redis Extension for Flask Applications

Resources

License

AGPL-3.0, AGPL-3.0 licenses found

Licenses found

AGPL-3.0
LICENSE
AGPL-3.0
LICENSE.rst

Stars

Watchers

Forks

Packages

No packages published

Languages