A nice way to use Redis in your Flask app
Likely abandoned. No release or commit for years (last release over 7 years ago).
pip install flask-redisflask-redis
A nice way to use Redis in your Flask app.
Configuration
Start by installing the extension with pip install flask-redis.
Once that's done, configure it within your Flask config.
Set the URL of your Redis instance like this:
REDIS_URL = "redis://:password@localhost:6379/0"
If you wanna connect to a Unix socket,
you can specify it like "unix://:password@/path/to/socket.sock?db=0".
Usage
Setup
To add a Redis client to your application:
from flask import Flask
from flask_redis import FlaskRedis
app = Flask(__name__)
redis_client = FlaskRedis(app)
or if you prefer, you can do it the other way around:
redis_client = FlaskRedis(app)
def create_app():
app = Flask(__name__)
redis_client.init_app(app)
return app
Accessing Redis
The redis client you created above from FlaskRedis acts just like a regular Redis instance from the redis-py library: