Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

sanchitrk/Flask-RedisClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask-RedisClient

This is a simple Flask extension that allows you to use Redis in your application.

Installation & Basic Configuration

$ (venv) pip install Flask-RedisClient

Configure it within your Flask config

REDIS_URL = "redis://:password@localhost:6379/0"

Usage

Add Redis Client to your application

from flask import Flask
from flask_redisclient import RedisClient

app = Flask(__name__)
redis_client = RedisClient(app)

or if you are using app factory pattern

redis_client = RedisClient()
def create_app():
    app = Flask(__name__)
    redis_client.init_app(app)
    return app

Accessing Redis Client

The redis_client.connection returns a regular Redis instance from the redis-py package.

You can use all the methods and features available in redis-py package.

from app import redis_client

@app.route('/')
def index():
    redis_conn = redis_client.connection
    return redis_conn.get('world')

About

A Simple Flask Redis Client

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages