mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
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:
20
app/clients/redis/redis_client.py
Normal file
20
app/clients/redis/redis_client.py
Normal 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)
|
||||
Reference in New Issue
Block a user