2013-07-09 31 views
1

我试图使用Django,Redis的using Unix sockets rather than a TCP connectionDjango的redis的配置使用套接字而不是TCP

这是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', 
     }, 
    }, 
} 

,这是Redis的配置的提取物文件在/etc/redis/6379.conf

# 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例外,CON期间代表一个错误nection。有关这个配置的问题是什么的想法?

P.S.我的Django版本是1.5.1,django-redis是3.3,并且hiredis是0.0.1

回答

2

编辑:显然我读的缓存提供商错了,下面的答案是django-redis-cache,而不是django-redis的解决方案。我会让答案保持不变,因为更改缓存提供程序和使用此配置似乎已解决了问题。

您不应该需要unix:前缀,并且后端设置看起来很奇怪;

'default': { 
    'BACKEND': 'redis_cache.RedisCache', 
    'LOCATION': '/tmp/redis.sock', 
    'OPTIONS': { ... 
+0

将'LOCATION' chagning'changning'建议引发'错误格式'/ tmp/redis.sock''消息引发'错误配置'异常。另外,RedisCache类的位置是正确的(我查看了源代码)。 –

+1

@JosvicZammit奇,可能是一个版本的差异,然后,[本页](https://github.com/sebleier/django-redis-cache)似乎同意我的看法。 –

+0

问题是这样的:我使用['django-redis'](https://django-redis.readthedocs.org/en/latest/)而不是['django-redis-cache'](https:/ /github.com/sebleier/django-redis-cache)。我切换到'django-redis-cache',现在按照规定工作。请编辑你的答案,指出不是['django-redis-cache'](https://github.com/sebleier/django-redis-cache)正在被使用,并让我知道,以便我标记它是正确的。谢谢! –