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

Commit

Permalink
Merge pull request #9 from jpopelka/redis-host-port-db
Browse files Browse the repository at this point in the history
Allow to set Redis host, port and db
  • Loading branch information
jpopelka authored Jul 8, 2020
2 parents 0de2e6e + 7ca5222 commit b4d1e9b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions persistentdict/dict_in_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,23 @@ class PersistentDict:
can be strings only, so we use json serialization
"""

def __init__(self, hash_name="dict-in-redis"):
def __init__(
self,
hash_name="dict-in-redis",
redis_host=None,
redis_port=None,
redis_db=None,
redis_password=None,
):
"""
:param hash_name: name of the dictionary/hash [1] we store all the info in
"""
self.db = Redis(
host=getenv("REDIS_SERVICE_HOST", "localhost"),
port=getenv("REDIS_SERVICE_PORT", "6379"),
db=1, # 0 is used by Celery
host=redis_host or getenv("REDIS_SERVICE_HOST", "localhost"),
port=redis_port or getenv("REDIS_SERVICE_PORT", "6379"),
db=redis_db or 1, # 0 is used by Celery
password=redis_password or getenv("REDIS_PASSWORD"),
decode_responses=True,
)
self.hash = hash_name
Expand Down

0 comments on commit b4d1e9b

Please sign in to comment.