【发布时间】:2015-01-14 20:18:27
【问题描述】:
我正在使用 django-cache-redis,但我陷入了以下悖论:
# 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(最近一次调用最后一次): redis.exceptions.ConnectionError:连接到 127.0.0.1:20789:0 时出现错误 -2。名称或服务未知。
注意host、port和db在这两种情况下都是一样的。
import redis的使用已经是debug了;使用 redis-ctl 也可以。我还尝试按照this question从127.0.0.1更改为localhost,但没有成功。
知道这可能是什么吗?
我的CACHES 配置已经是最小的了:
CACHES = {
'default': {
'BACKEND': 'redis_cache.cache.RedisCache',
'LOCATION': '127.0.0.1:20789:0',
'TIMEOUT': 60*60*24,
}
}
【问题讨论】: