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
Installation
Install with pip:
pip install Flask-Redis-Sentinel
Basic usage
from flask_redis_sentinel import SentinelExtension
redis_sentinel = SentinelExtension()
redis_connection = redis_sentinel.default_connection
# Later when you create application
app = Flask(...)
redis_sentinel.init_app(app)
You can configure Redis connection parameters using REDIS_URL Flask configuration variable with redis+sentinel URL scheme:
redis+sentinel://localhost:26379[,otherhost:26379,...]/mymaster/0 redis+sentinel://localhost:26379[,otherhost:26379,...]/mymaster/0?socket_timeout=0.1 redis+sentinel://localhost:26379[,otherhost:26379,...]/mymaster/0?sentinel_socket_timeout=0.1 redis+sentinel://:sentinel-secret-password@localhost:26379[,otherhost:26379,...]/mymaster/0?sentinel_socket_timeout=0.1
The extension also supports URL schemes as supported by redis-py for connecting to an instance directly without Sentinel:
redis://[:password]@localhost:6379/0 rediss://[:password]@localhost:6379/0 unix://[:password]@/path/to/socket.sock?db=0
Flask-And-Redis style config variables are also supported for easier migration, but the extension will log a DeprecationWarning:
REDIS_HOST = 'localhost' REDIS_PORT = 6379 REDIS_DB = 0
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_redis_sentinel import SentinelExtension
redis_sentinel = SentinelExtension()
master1 = redis_sentinel.master_for('service1')
master2 = redis_sentinel.master_for('service2')
slave1 = redis_sentinel.slave_for('service1')
Accessing redis-py’s Sentinel instance
from flask_redis_sentinel import SentinelExtension
from flask import jsonify, Flask
app = Flask('test')
redis_sentinel = SentinelExtension(app=app)
@app.route('/')
def index():
slaves = redis_sentinel.sentinel.discover_slaves('service1')
return jsonify(slaves=slaves)
Change log
v2.0.0
Connections are now thread-local to avoid race conditions after Redis master failover
Removed support for REDIS_{HOST, PORT, DB} config variables
v1.0.0
Moved URL handling code to a separate library, redis_sentinel_url
Backward-incompatible change:
# Old redis+sentinel://host:port/service?slave=true
Should now be written as:
# New redis+sentinel://host:port/service?client_type=slave
v0.2.0
Use config variables other than REDIS_{HOST, PORT, DB} even if REDIS_URL is used
Minor refactoring
v0.1.0
Initial release
Metadata
Release files for Flask-Redis-Sentinel 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Flask-Redis-Sentinel-2.0.1.tar.gz | 8.3 kB | Without provenance | Details for Flask-Redis-Sentinel-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Flask_Redis_Sentinel-2.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for Flask_Redis_Sentinel-2.0.1-py2.py3-none-any.whl |
Total release size: 15.1 kB
Release files / Flask-Redis-Sentinel-2.0.1.tar.gz
| Download URL | Flask-Redis-Sentinel-2.0.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a17ef135f607f1531fd80a283368ef5f11ecf5a4237b48fd192549e8c8998f02
|
|
BLAKE2b-256 checksum How to use checksums |
7f11ab88b51564ea413c94c5a6b31df6b2f5b074d54c2952496734bf73bb0130
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / Flask_Redis_Sentinel-2.0.1-py2.py3-none-any.whl
| Download URL | Flask_Redis_Sentinel-2.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
0deb2bef4977144a008bae2457c931ff8b1f3f97dce94c09003ed360e39f89a4
|
|
BLAKE2b-256 checksum How to use checksums |
2a60a19904c7342ac87f0343e6b3476fcaaf62015eb5443e1424d6830359552f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Flask-Redis-Sentinel 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.