comparison core/services.py @ 880:bab6b1eac1e2

Merge with upstream.
author Brian Neal <bgneal@gmail.com>
date Sat, 03 Jan 2015 19:19:03 -0600
parents a423e8fd082d
children
comparison
equal deleted inserted replaced
875:d5d8e90d08b5 880:bab6b1eac1e2
9 # Redis connection and database settings 9 # Redis connection and database settings
10 10
11 REDIS_HOST = getattr(settings, 'REDIS_HOST', 'localhost') 11 REDIS_HOST = getattr(settings, 'REDIS_HOST', 'localhost')
12 REDIS_PORT = getattr(settings, 'REDIS_PORT', 6379) 12 REDIS_PORT = getattr(settings, 'REDIS_PORT', 6379)
13 REDIS_DB = getattr(settings, 'REDIS_DB', 0) 13 REDIS_DB = getattr(settings, 'REDIS_DB', 0)
14 REDIS_SOCKET = getattr(settings, 'REDIS_UNIX_SOCKET', None)
14 15
15 16
16 def get_redis_connection(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB): 17 def get_redis_connection(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB,
18 unix_socket_path=REDIS_SOCKET):
17 """ 19 """
18 Create and return a Redis connection using the supplied parameters. 20 Create and return a Redis connection using the supplied parameters.
19 21
20 """ 22 """
23 if unix_socket_path:
24 return redis.StrictRedis(unix_socket_path=unix_socket_path, db=db)
21 return redis.StrictRedis(host=host, port=port, db=db) 25 return redis.StrictRedis(host=host, port=port, db=db)