Splendor
Splendor

Reputation: 1396

Problem configuring django-redis with ElastiCache Redis (cluster mode enabled)

I am working on Django project that currently uses ElastiCache Redis 3.2.6 with multiple nodes in a "master/slave" configuration using the "redis_cache.RedisCache" backend. This works fine currently.

However, I am in the process of migrating the project to a new ElastiCache Redis 5.0.3 instance with cluster mode enabled turned on. I have been unsuccessful in finding any documented method of configuring a connection from Django to ElastiCache's configuration endpoint for a Redis cluster. The closest thing I've found is this comment on the django-redis GitHub but when I try that configuration I get an error that says:

rediscluster.exceptions.RedisClusterException: Redis Cluster cannot be connected. Please provide at least one reachable node.

Is there some better way to accomplish this that I'm missing?

Upvotes: 0

Views: 2828

Answers (1)

Splendor
Splendor

Reputation: 1396

I figured it out. Here's a working config:

"default": {
    'BACKEND': 'django_redis.cache.RedisCache',
    'LOCATION':"redis://mycluster.foo.clustercfg.use1.cache.amazonaws.com/0",
    'OPTIONS': {
        'REDIS_CLIENT_CLASS': 'rediscluster.StrictRedisCluster',
        'CONNECTION_POOL_CLASS': 'rediscluster.connection.ClusterConnectionPool',
        'CONNECTION_POOL_KWARGS': {
            'skip_full_coverage_check': True  # AWS ElasticCache has disabled CONFIG commands
         }
    }
}

Upvotes: 3

Related Questions