{"id":17161641,"url":"https://github.com/eastwu5788/flask-redis","last_synced_at":"2025-10-17T08:32:26.019Z","repository":{"id":45006744,"uuid":"118998217","full_name":"Eastwu5788/Flask-Redis","owner":"Eastwu5788","description":"Redis extension for Flask","archived":false,"fork":false,"pushed_at":"2023-05-01T23:13:48.000Z","size":103,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T05:12:44.386Z","etag":null,"topics":["flask","redis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Eastwu5788.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGE.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-26T03:01:57.000Z","updated_at":"2025-02-19T09:16:44.000Z","dependencies_parsed_at":"2024-11-15T06:01:32.657Z","dependency_job_id":null,"html_url":"https://github.com/Eastwu5788/Flask-Redis","commit_stats":{"total_commits":44,"total_committers":2,"mean_commits":22.0,"dds":0.09090909090909094,"last_synced_commit":"517ecbfb79493991782ff4c8f2b8f6cf59b88077"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eastwu5788%2FFlask-Redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eastwu5788%2FFlask-Redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eastwu5788%2FFlask-Redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eastwu5788%2FFlask-Redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Eastwu5788","download_url":"https://codeload.github.com/Eastwu5788/Flask-Redis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724629,"owners_count":21151561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","redis"],"created_at":"2024-10-14T22:43:33.701Z","updated_at":"2025-10-17T08:32:20.977Z","avatar_url":"https://github.com/Eastwu5788.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Flask-Redis\n============\n\n.. image:: https://github.com/Eastwu5788/Flask-Redis/actions/workflows/intergration.yml/badge.svg\n    :target: https://github.com/Eastwu5788/Flask-Redis/actions/workflows/intergration.yml\n.. image:: https://codecov.io/gh/Eastwu5788/Flask-Redis/branch/master/graph/badge.svg?token=GIHTW0XDK7\n    :target: https://codecov.io/gh/Eastwu5788/Flask-Redis\n.. image:: https://badge.fury.io/py/flask-redis-ext.svg\n    :target: https://badge.fury.io/py/flask-redis-ext\n\nFlask-Redis is an extension for Flask that adds support for Redis to your application. It aims to simplify manage multi\nRedis databases with Flask.\n\nInstalling\n============\n\nInstall and update using pip:\n\n::\n\n  pip install flask-redis-ext\n\nA Simple Example\n==================\n\n::\n\n    from flask import Flask\n    from flask-redis import Redis\n\n    redis = Redis()\n    app = Flask(__name__)\n\n    app.config[\"REDIS_PREFIX\"] = \"EG:\"\n    app.config[\"REDIS_URL\"] = \"redis://:password@host:port/db\"\n    app.config[\"REDIS_DECODE_RESPONSES\"] = True\n    redis.init_app(app)\n\n    redis.get(\"test\")\n\n\nMultiple Databases\n====================\n\n::\n\n    from flask import Flask\n    from flask_redis import Redis\n\n    redis = Redis()\n    app = Flask(__name__)\n\n    app.config[\"REDIS_BINDS\"] = {\n        \"default\": {\n            \"REDIS_URL\": \"redis://:password@host:port/db\",\n        },\n        \"DB12\": {\n            \"REDIS_PREFIX\": \"EG12:\",\n            \"REDIS_URL\": \"redis://:password@host:port/db\",\n        },\n        \"DB13\": {\n            \"REDIS_PREFIX\": \"EG13:\",\n            \"REDIS_URL\": \"redis://:password@host:port/db\",\n        }\n    }\n    redis.init_app(app)\n\n    # use default database\n    redis.set(\"key1\", \"value1)\n    # use db12\n    redis[\"DB12\"].set(\"key1\", \"value1\")\n    # use getter\n    redis.DB12.set(\"key1\", \"value1)\n\nSupport Parameter\n====================\n\n========================   ==============================   =========================================================\n     Parameter                    Explain                     Example\n========================   ==============================   =========================================================\n   REDIS_PREFIX             storage key prefix                    app.config[\"REDIS_PREFIX\"] = \"EG:\"\n   REDIS_BINDS              bind multi databases                            --\n   REDIS_URL                    redis url                               redis://xx\nREDIS_DEFAULT_BIND_KEY         default redis bind key           app.config[\"REDIS_DEFAULT_BIND_KEY\"] = \"default\"\nREDIS_CONNECTION_POOL         custom connection pool         app.config[\"REDIS_CONNECTION_POOL\"] = ConnectionPool()\n========================   ==============================   =========================================================\n\n\nRedis Parameter\n================\n\nWe support all of the origin redis init parameter which should be started with \"REDIS_\".\n`socket_timeout` should be config as `REDIS_SOCKET_TIMEOUT`.\n`encoding` should be config as `REDIS_ENCODING`. All other parameters follow the same rules.\n\n\nRedis Prefix\n===============\n\n`Flask-Redis` support auto add key prefix for all of the `DataAccessCommands`.\n\nFor example, if you use `redis.set(\"k\", \"v\")` to store value at `k` and redis prefix is `EG:`, the really key in redis\nstorage is \"EG:k\".\n\nRedis prefix is a globally effective configuration parameter. if you don't want to add prefix for special key,\nyou can add `-` character to ignore prefix. e.g. `redis.set(\"-k\", \"v\")` which will store really 'k' as key in redis.\n\nDecorator `cached`\n====================\n\n`Flask-Redis` support `cached` decorator to cache function result.\n\n::\n\n    @redis.cached(key=\"{k1}:{k2}:{k3}\", timeout=10)\n    def cache_func(sf, k1, k2=1, **kwargs):\n        return sf.v1\n\n\nCluster Mode\n================\n\n`Flask-Redis` support redis cluster mode. There are multiple ways in which a cluster instance can be created:\n\nSpecially, `Flask-Redis` don't support multi cluster, therefore `REDIS_BINDS` is invalid for this mode.\n\n* Using the Redis URL specification:\n\n::\n\n    from flask import Flask\n    from flask_redis import RedisCluster\n\n    app = Flask(__name__)\n    app.config[\"REDIS_DECODE_RESPONSES\"] = True\n    app.config[\"REDIS_PREFIX\"] = \"CLU:\"\n    app.config[\"REDIS_URL\"] = \"redis://:@127.0.0.1:7001/0\"\n\n    redis = RedisCluster()\n    redis.init_app(app)\n\n    print(redis.get_nodes())\n    redis.set(\"K\", \"V\")\n\n\n* Using `host` and `port` arguments:\n\n::\n\n    from flask import Flask\n    from flask_redis import RedisCluster\n\n    app = Flask(__name__)\n    app.config[\"REDIS_DECODE_RESPONSES\"] = True\n    app.config[\"REDIS_PREFIX\"] = \"CLU:\"\n    app.config[\"REDIS_HOST\"] = \"127.0.0.1\"\n    app.config[\"REDIS_PORT\"] = \"7001\"\n\n    redis = RedisCluster()\n    redis.init_app(app)\n\n    print(\"redis.get_nodes()\")\n    redis.set(\"K\", \"V\")\n\n\nSentinel Mode\n==================\n\n`Flask-Redis` support sentinel mode. You can use a Sentinel connection to discover the master and slaves\nnetwork address. You can also create redis client connections from a sentinel instance.\n\n::\n\n    from flask import Flask\n    from flask_redis import Sentinel\n\n    app = Flask(__name__)\n\n    app.config[\"REDIS_PREFIX\"] = \"SEN:\"\n    app.config[\"REDIS_SENTINELS\"] = [(\"192.168.1.189\", 18001)]\n    app.config[\"REDIS_SENTINEL_KWARGS\"] = {\n        \"socket_timeout\": 0.1\n    }\n    app.config[\"REDIS_CONNECTION_KWARGS\"] = {\n        \"decode_responses\": True\n    }\n\n    rds = Sentinel()\n    rds.init_app(app)\n\n    print(rds.discover_master(\"mymaster\"))\n    print(rds.discover_slaves(\"mymaster\"))\n\n    master = rds.master_for(\"mymaster\")\n    slave = rds.slave_for(\"mymaster\")\n\n    master.set(\"k\", \"v\")\n    slave.get(\"k\")\n\n\nSentinel mode is different from other simple and Cluster mode. in this mode, you should use `REDIS_SENTINELS` parameter\nto config connection info. You will get details about sentinel mode parameter at below:\n\n========================   ==============================   =========================================================\n     Parameter                    Explain                     Example\n========================   ==============================   =========================================================\n    REDIS_SENTINELS             sentinel connections        app.config[\"REDIS_SENTINELS\"] = [(\"192.168.1.189\", 18001)]\n REDIS_SENTINEL_KWARGS      sentinel kwargs for Sentinel    app.config[\"REDIS_SENTINEL_KWARGS\"] = {\"socket_timeout\": 0.1}\n REDIS_CONNECTION_KWARGS    redis connection kwargs         app.config[\"REDIS_CONNECTION_KWARGS\"] = {\"decode_responses\": True}\n========================   ==============================   =========================================================\n\n\nLinks\n======\n\n* Release: https://pypi.org/project/flask-redis-ext/\n* Code: https://github.com/Eastwu5788/Flask-Redis\n* Issue tracker: https://github.com/Eastwu5788/Flask-Redis/issues\n* Test status: https://coveralls.io/github/Eastwu5788/Flask-Redis\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feastwu5788%2Fflask-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feastwu5788%2Fflask-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feastwu5788%2Fflask-redis/lists"}