first commit
This commit is contained in:
17
helix/db/redis_manager.py
Normal file
17
helix/db/redis_manager.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import json
|
||||
|
||||
import redis
|
||||
|
||||
|
||||
class RedisManager(object):
|
||||
@staticmethod
|
||||
def get_redis_connection(vcap_env, heroku_redis_url):
|
||||
if vcap_env:
|
||||
redis_env = json.loads(vcap_env)['rediscloud'][0]['credentials']
|
||||
return redis.Redis(host=redis_env['hostname'],
|
||||
port=int(redis_env['port']),
|
||||
password=redis_env['password'])
|
||||
elif heroku_redis_url:
|
||||
return redis.Redis.from_url(heroku_redis_url)
|
||||
else:
|
||||
return redis.Redis(host='localhost', port=6379, db=0)
|
||||
Reference in New Issue
Block a user