Mercurial > public > sg101
changeset 879:a423e8fd082d
Access redis via UNIX socket.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 03 Jan 2015 18:22:48 -0600 |
parents | fb0d2871afa4 |
children | bab6b1eac1e2 4dd7e1b5efe8 |
files | core/services.py requirements.txt requirements_dev.txt sg101/settings/base.py |
diffstat | 4 files changed, 10 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/core/services.py Sat Jan 03 14:24:52 2015 -0600 +++ b/core/services.py Sat Jan 03 18:22:48 2015 -0600 @@ -11,11 +11,15 @@ REDIS_HOST = getattr(settings, 'REDIS_HOST', 'localhost') REDIS_PORT = getattr(settings, 'REDIS_PORT', 6379) REDIS_DB = getattr(settings, 'REDIS_DB', 0) +REDIS_SOCKET = getattr(settings, 'REDIS_UNIX_SOCKET', None) -def get_redis_connection(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB): +def get_redis_connection(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB, + unix_socket_path=REDIS_SOCKET): """ Create and return a Redis connection using the supplied parameters. """ + if unix_socket_path: + return redis.StrictRedis(unix_socket_path=unix_socket_path, db=db) return redis.StrictRedis(host=host, port=port, db=db)
--- a/requirements.txt Sat Jan 03 14:24:52 2015 -0600 +++ b/requirements.txt Sat Jan 03 18:22:48 2015 -0600 @@ -9,7 +9,7 @@ bleach==1.4 pytz==2013b queued-search==2.1.0 -queues==0.6.3 +hg+https://bgneal@bitbucket.org/bgneal/queues@862e884#egg=queues redis==2.7.2 repoze.timeago==0.5 -e git+https://github.com/notanumber/xapian-haystack.git@37add92bc43fe50bf165e91f370269c26272f1eb#egg=xapian_haystack-dev
--- a/requirements_dev.txt Sat Jan 03 14:24:52 2015 -0600 +++ b/requirements_dev.txt Sat Jan 03 18:22:48 2015 -0600 @@ -10,7 +10,7 @@ bleach==1.4 pytz==2013b queued-search==2.1.0 -queues==0.6.3 +hg+https://bgneal@bitbucket.org/bgneal/queues@862e884#egg=queues redis==2.7.2 repoze.timeago==0.5 -e git+https://github.com/notanumber/xapian-haystack.git@37add92bc43fe50bf165e91f370269c26272f1eb#egg=xapian_haystack-master
--- a/sg101/settings/base.py Sat Jan 03 14:24:52 2015 -0600 +++ b/sg101/settings/base.py Sat Jan 03 18:22:48 2015 -0600 @@ -202,14 +202,13 @@ ####################################################################### # Redis integration & settings ####################################################################### -REDIS_HOST = 'localhost' -REDIS_PORT = 6379 +REDIS_UNIX_SOCKET = '/var/run/redis/redis.sock' REDIS_DB = 0 ####################################################################### # Celery integration & settings ####################################################################### -BROKER_URL = 'redis://localhost:6379/1' +BROKER_URL = 'redis+socket:///var/run/redis/redis.sock?virtual_host=1' BROKER_POOL_LIMIT = 10 CELERY_TIMEZONE = TIME_ZONE @@ -301,7 +300,7 @@ # Asynchronous settings (queues, queued_search, redis, celery, etc) ####################################################################### QUEUE_BACKEND = 'redisd' -QUEUE_REDIS_CONNECTION = 'localhost:6379' +QUEUE_REDIS_UNIX_SOCKET = REDIS_UNIX_SOCKET QUEUE_REDIS_DB = 0 #######################################################################