我正在尝试使用django-redis using Unix sockets rather than a TCP connection:
这是settings.py
配置:
CACHES = {
'default': {
'BACKEND': 'redis_cache.cache.RedisCache',
'LOCATION': 'unix:/tmp/redis.sock:1',
'OPTIONS': {
'PASSWORD': '',
'PICKLE_VERSION': -1, # default
'PARSER_CLASS': 'redis.connection.HiredisParser',
'CLIENT_CLASS': 'redis_cache.client.DefaultClient',
},
},
}
这是/etc/redis/6379.conf
的redis配置文件的摘录:
# Specify the path for the unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
#
unixsocket /tmp/redis.sock
unixsocketperm 755
我仍然收到ConnectionInterrumped
异常,代表连接期间的错误。关于这个配置的问题是什么想法?
P.S。我的Django版本为1.5.1
,django-redis为3.3
,hiredis为0.0.1
。
答案 0 :(得分:2)
编辑:显然我读错了缓存提供程序,下面的答案是django-redis-cache
的解决方案,而不是django-redis
。我会保留答案,因为更改缓存提供程序并使用此配置似乎已解决了问题。
您不需要unix:
前缀,后端设置看起来很奇怪;
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': '/tmp/redis.sock',
'OPTIONS': { ...