bgneal@508: """ bgneal@508: This module provides a common way for the various apps to integrate with services bgneal@508: that are installed at this site. bgneal@508: bgneal@508: """ bgneal@508: from django.conf import settings bgneal@508: import redis bgneal@508: bgneal@508: # Redis connection and database settings bgneal@508: bgneal@508: REDIS_HOST = getattr(settings, 'REDIS_HOST', 'localhost') bgneal@508: REDIS_PORT = getattr(settings, 'REDIS_PORT', 6379) bgneal@508: REDIS_DB = getattr(settings, 'REDIS_DB', 0) bgneal@879: REDIS_SOCKET = getattr(settings, 'REDIS_UNIX_SOCKET', None) bgneal@508: bgneal@508: bgneal@879: def get_redis_connection(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB, bgneal@879: unix_socket_path=REDIS_SOCKET): bgneal@508: """ bgneal@508: Create and return a Redis connection using the supplied parameters. bgneal@508: bgneal@508: """ bgneal@879: if unix_socket_path: bgneal@879: return redis.StrictRedis(unix_socket_path=unix_socket_path, db=db) bgneal@519: return redis.StrictRedis(host=host, port=port, db=db)