0

I'm using django-cache-redis, and I'm stuck in the following paradox:

# in `python manage.py shell`
import redis
r = redis.StrictRedis(host='127.0.0.1', port=20789, db=0)
r.set('foo', 'bar')  # returns True

from django.core.cache import cache
cache.set('foo', 'bar', 1)  # raises redis.exceptions.ConnectionError

Traceback (most recent call last): redis.exceptions.ConnectionError: Error -2 connecting to 127.0.0.1:20789:0. Name or service not known.

Notice that the host, the port and the db are the same in both cases.

The use of import redis was already a debug; using redis-ctl also works. I also tried changing from 127.0.0.1 to localhost, as per this question, without success.

Any idea of what this might be?

My CACHES config is already the minimal one:

CACHES = {
    'default': {
        'BACKEND': 'redis_cache.cache.RedisCache',
        'LOCATION': '127.0.0.1:20789:0',
        'TIMEOUT': 60*60*24,
    }
}
Community
  • 1
  • 1
Jorge Leitao
  • 19,085
  • 19
  • 85
  • 121

1 Answers1

2

I'm guessing, but you have:

'LOCATION': '127.0.0.1:20789:0'

Whereas readme for django-redis-cache specifies:

'LOCATION': '<host>:<port>'

i.e. without the :<db> on the end

https://github.com/sebleier/django-redis-cache

Anentropic
  • 32,188
  • 12
  • 99
  • 147