fix set and get in redis_client

This commit is contained in:
Kenneth Kehl
2024-06-07 09:07:42 -07:00
parent 4321e31377
commit da96edbfcd
6 changed files with 133 additions and 42 deletions

View File

@@ -133,19 +133,13 @@ class RedisClient:
else:
return False
def raw_set(self, key, value, ex=None, px=None, nx=False, xx=False):
self.redis_store.set(key, value, ex, px, nx, xx)
def set(
self, key, value, ex=None, px=None, nx=False, xx=False, raise_exception=False
):
key = prepare_value(key)
value = prepare_value(value)
if self.active:
try:
self.redis_store.set(key, value, ex, px, nx, xx)
except Exception as e:
self.__handle_exception(e, raise_exception, "set", key)
self.redis_store.set(key, value, ex, px, nx, xx)
def incr(self, key, raise_exception=False):
key = prepare_value(key)
@@ -155,16 +149,10 @@ class RedisClient:
except Exception as e:
self.__handle_exception(e, raise_exception, "incr", key)
def raw_get(self, key):
return self.redis_store.get(key)
def get(self, key, raise_exception=False):
key = prepare_value(key)
if self.active:
try:
return self.redis_store.get(key)
except Exception as e:
self.__handle_exception(e, raise_exception, "get", key)
return self.redis_store.get(key)
return None