mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Initial SPIKE into redis for cache
This commit is contained in:
22
app/clients/redis/redis_client.py
Normal file
22
app/clients/redis/redis_client.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import redis
|
||||
|
||||
|
||||
class RedisClient:
|
||||
def init_app(self, app, *args, **kwargs):
|
||||
self.active = app.config.get('REDIS_ENABLED')
|
||||
self.redis = None
|
||||
|
||||
if self.active:
|
||||
self.redis = redis.StrictRedis(
|
||||
app.config.get('REDIS_HOST'),
|
||||
app.config.get('REDIS_PORT')
|
||||
)
|
||||
|
||||
def set(self, key, value):
|
||||
self.redis.set(key, value)
|
||||
|
||||
def get(self, key):
|
||||
return self.redis.get(key)
|
||||
|
||||
def incr(self, key):
|
||||
return self.redis.incr(key)
|
||||
Reference in New Issue
Block a user