Skip to content
This repository was archived by the owner on Aug 22, 2022. It is now read-only.

Commit b4d1e9b

Browse files
authored
Merge pull request #9 from jpopelka/redis-host-port-db
Allow to set Redis host, port and db
2 parents 0de2e6e + 7ca5222 commit b4d1e9b

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

persistentdict/dict_in_redis.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,23 @@ class PersistentDict:
5151
can be strings only, so we use json serialization
5252
"""
5353

54-
def __init__(self, hash_name="dict-in-redis"):
54+
def __init__(
55+
self,
56+
hash_name="dict-in-redis",
57+
redis_host=None,
58+
redis_port=None,
59+
redis_db=None,
60+
redis_password=None,
61+
):
5562
"""
5663
5764
:param hash_name: name of the dictionary/hash [1] we store all the info in
5865
"""
5966
self.db = Redis(
60-
host=getenv("REDIS_SERVICE_HOST", "localhost"),
61-
port=getenv("REDIS_SERVICE_PORT", "6379"),
62-
db=1, # 0 is used by Celery
67+
host=redis_host or getenv("REDIS_SERVICE_HOST", "localhost"),
68+
port=redis_port or getenv("REDIS_SERVICE_PORT", "6379"),
69+
db=redis_db or 1, # 0 is used by Celery
70+
password=redis_password or getenv("REDIS_PASSWORD"),
6371
decode_responses=True,
6472
)
6573
self.hash = hash_name

0 commit comments

Comments
 (0)