1

I'm attempting to use django-redis using Unix sockets rather than a TCP connection:

This is the settings.py configuration:

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

and this is an extract of the redis config file at /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

Still I receive a ConnectionInterrumped exception, which stands for an error during connection. Any ideas about what this configuration's issue is?

P.S. My Django version is 1.5.1, django-redis is 3.3 and hiredis is 0.0.1.

Joseph Victor Zammit
  • 14,760
  • 10
  • 76
  • 102

1 Answers1

2

EDIT: Apparently I read the cache provider wrong, the below answer is the solution for django-redis-cache, not django-redis. I'll let the answer remain though, since changing cache provider and using this config seems to have solved the problem.

You should not need the unix: prefix, and the backend setting looks strange;

'default': {
    'BACKEND': 'redis_cache.RedisCache',
    'LOCATION': '/tmp/redis.sock',
    'OPTIONS': { ...
Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • chagning `LOCATION` to what you suggest raises an `Improperly configured` exception with message `Incorrect format '/tmp/redis.sock'`. Also, the location of `RedisCache` class is correct (I looked at the sources). – Joseph Victor Zammit Jul 09 '13 at 15:39
  • 1
    @JosvicZammit Odd, may be a version difference then, [this page](https://github.com/sebleier/django-redis-cache) seems to agree with me. – Joachim Isaksson Jul 09 '13 at 15:52
  • The problem is this: I'm using [`django-redis`](https://django-redis.readthedocs.org/en/latest/) and not [`django-redis-cache`](https://github.com/sebleier/django-redis-cache). I switched to `django-redis-cache`, and now things work as prescribed. Please edit your answer to point out that not [`django-redis-cache`](https://github.com/sebleier/django-redis-cache) is being used and let me know so that I mark it as correct. Thanks! – Joseph Victor Zammit Jul 09 '13 at 16:15