Refactored the initialisation of the redis client to follow the model used in the StatsdClient.

Basically wrapped the client so we can enable/disable, exception handle and so on.
This commit is contained in:
Martyn Inglis
2016-11-10 11:50:49 +00:00
parent eb94fe6c0a
commit aabda3f83e
4 changed files with 26 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
from flask.ext.redis import FlaskRedis
class RedisClient:
active = False
redis_store = FlaskRedis()
def init_app(self, app):
self.active = app.config.get('REDIS_ENABLED')
if self.active:
self.redis_store.init_app(app)
def set(self, key, value):
if self.active:
self.redis_store.set(key, value)
def get(self, key):
if self.active:
self.redis_store.get(key)