Here's my class for providing a singleton instance of a Redis connection. What do you think?
from redis import StrictRedis
import os
class RedisConnection(object):
REDIS_URL = os.environ['REDIS_URL']
def __init__(self):
self._redis = StrictRedis.from_url(self.REDIS_URL)
def redis(self):
return self._redis
the_instance = None
@classmethod
def singleton(cls):
if cls.the_instance == None:
print "assigning!"
cls.the_instance = cls().redis()
return cls.the_instance