Mercurial > public > sg101
diff gpp/core/whos_online.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 | 3fe60148f75c |
children | f72ace06658a |
line wrap: on
line diff
--- a/gpp/core/whos_online.py Sun Dec 04 03:05:21 2011 +0000 +++ b/gpp/core/whos_online.py Sun Dec 04 19:53:27 2011 +0000 @@ -4,21 +4,17 @@ """ import logging -from django.conf import settings import redis +from core.services import get_redis_connection + + # Users and visitors each have 2 sets that we store in a Redis database: # a current set and an old set. Whenever a user or visitor is seen, the # current set is updated. At some interval, the current set is renamed # to the old set, thus destroying it. At any given time, the union of the # current and old sets is the "who's online" set. -# Redis connection and database settings - -HOST = getattr(settings, 'WHOS_ONLINE_REDIS_HOST', 'localhost') -PORT = getattr(settings, 'WHOS_ONLINE_REDIS_PORT', 6379) -DB = getattr(settings, 'WHOS_ONLINE_REDIS_DB', 0) - # Redis key names: USER_CURRENT_KEY = "wo_user_current" USER_OLD_KEY = "wo_user_old" @@ -39,7 +35,7 @@ Create and return a Redis connection. Returns None on failure. """ try: - conn = redis.Redis(host=HOST, port=PORT, db=DB) + conn = get_redis_connection() return conn except redis.RedisError, e: logger.error(e)