Skip to content

Commit

Permalink
Sirope can receive a customized redis object.
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltasarq committed Mar 24, 2022
1 parent 2646a07 commit 5afb4c2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sirope/sirope_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
class Sirope:
OID_ID = "__oid__"

def __init__(self):
self._redis = redis.Redis()
def __init__(self, redis_obj: redis.Redis=None):
"""Creates a Sirope object from a given Redis.
:param redis: A Redis object or None.
"""
if not redis_obj:
self._redis = redis.Redis()
else:
self._redis = redis_obj
self._indexes = SafeIndex.get(self._redis)

def save(self, obj: object) -> OID:
Expand Down

0 comments on commit 5afb4c2

Please sign in to comment.