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

463 Views Asked by At

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: enter image description here

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,
            }
        },
    )
1

There are 1 best solutions below

0
On

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.