Mercurial > public > sg101
comparison gpp/core/services.py @ 508:6f5fff924877
Created a centralized spot to get a Redis connection so that settings can be managed in one place.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 04 Dec 2011 19:53:27 +0000 |
parents | |
children | f72ace06658a |
comparison
equal
deleted
inserted
replaced
507:8631d32e6b16 | 508:6f5fff924877 |
---|---|
1 """ | |
2 This module provides a common way for the various apps to integrate with services | |
3 that are installed at this site. | |
4 | |
5 """ | |
6 from django.conf import settings | |
7 import redis | |
8 | |
9 # Redis connection and database settings | |
10 | |
11 REDIS_HOST = getattr(settings, 'REDIS_HOST', 'localhost') | |
12 REDIS_PORT = getattr(settings, 'REDIS_PORT', 6379) | |
13 REDIS_DB = getattr(settings, 'REDIS_DB', 0) | |
14 | |
15 | |
16 def get_redis_connection(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB): | |
17 """ | |
18 Create and return a Redis connection using the supplied parameters. | |
19 | |
20 """ | |
21 return redis.Redis(host=host, port=port, db=db) |