简体   繁体   中英

Flask-Caching not connecting to redis cluster in disabled cluster mode (aws hosted)

I am using the flask-caching library to use caching in my flask app. I am following the docs here: https://flask-caching.readthedocs.io/en/latest/#redisclustercache

When trying the connection on a cluster-enabled-mode cluster locally it works, however the app is stuck like this: 在此处输入图像描述

When I try to connect it to a hosted cluster in elasticache (disabled-cluster-mode) - I am using --tls auth.

Here is how the config looks like:

cache.init_app(
        app,
        config={
            "CACHE_TYPE": "RedisClusterCache",
            "CACHE_REDIS_PASSWORD": config.REDIS_PASSWORD,
            "CACHE_REDIS_CLUSTER": "host:port", # aws-hosted cluster
            "CACHE_REDIS_DB": 0, # use the db=0
            "BUILD_TlS": "yes",
            "CACHE_OPTIONS": { # Even tried passing the password as extra option
                "-a":config.REDIS_PASSWORD,
            }
        },
    )

For cluster mode disabled, you want to set CACHE_TYPE to RedisCache instead of RedisClusterCache .

When you set RedisClusterCache the client attempts to discover the nodes in the cluster and it fails as the CLUSTER NODES command is not available. You should see an error similar to Cluster mode is not enabled on this node .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM