|
@@ -113,15 +113,15 @@ def es_query(title: str, publish_time: int):
|
|
|
|
|
|
# ---------------------------------- redis ----------------------------------
|
|
|
def redis_client(cfg=None, host=None, port=None, db=None, password=None):
|
|
|
- if all([host is not None, port is not None, db is not None]):
|
|
|
- host, port, pwd, db = host, port, password, db
|
|
|
- else:
|
|
|
- _cfg = (cfg or redis_conf)
|
|
|
- host, port, pwd, db = _cfg['host'], _cfg['port'], _cfg['pwd'], _cfg['db']
|
|
|
+ _cfg = (cfg or redis_conf)
|
|
|
+ host = (host or _cfg['host'])
|
|
|
+ port = (port or _cfg['port'])
|
|
|
+ password = (password or _cfg['pwd'])
|
|
|
+ db = (db or _cfg['db'])
|
|
|
pool = redis.ConnectionPool(
|
|
|
host=host,
|
|
|
port=port,
|
|
|
- password=pwd,
|
|
|
+ password=password,
|
|
|
db=db
|
|
|
)
|
|
|
return redis.Redis(connection_pool=pool, decode_responses=True)
|