mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2025-07-12 03:58:16 +00:00
redis: add support to connect using unix socket
Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
parent
b59b0c248b
commit
c2a98b3dc7
@ -31,6 +31,9 @@ class EnvironmentSettings:
|
|||||||
# Redis
|
# Redis
|
||||||
REDIS_HOST: str = str(environ.get("REDIS_HOST"))
|
REDIS_HOST: str = str(environ.get("REDIS_HOST"))
|
||||||
REDIS_PORT: int = int(environ.get("REDIS_PORT", 6379))
|
REDIS_PORT: int = int(environ.get("REDIS_PORT", 6379))
|
||||||
|
REDIS_SOCKET: str | None = (
|
||||||
|
str(environ.get("REDIS_SOCKET")) if "REDIS_SOCKET" in environ else None
|
||||||
|
)
|
||||||
REDIS_NAME_SPACE: str = str(environ.get("REDIS_NAME_SPACE", "ta:"))
|
REDIS_NAME_SPACE: str = str(environ.get("REDIS_NAME_SPACE", "ta:"))
|
||||||
|
|
||||||
# ElasticSearch
|
# ElasticSearch
|
||||||
|
@ -17,11 +17,16 @@ class RedisBase:
|
|||||||
NAME_SPACE: str = EnvironmentSettings.REDIS_NAME_SPACE
|
NAME_SPACE: str = EnvironmentSettings.REDIS_NAME_SPACE
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.conn = redis.Redis(
|
kwargs = {
|
||||||
host=EnvironmentSettings.REDIS_HOST,
|
"decode_responses": True,
|
||||||
port=EnvironmentSettings.REDIS_PORT,
|
"host": EnvironmentSettings.REDIS_HOST,
|
||||||
decode_responses=True,
|
"port": EnvironmentSettings.REDIS_PORT,
|
||||||
)
|
}
|
||||||
|
|
||||||
|
if EnvironmentSettings.REDIS_SOCKET:
|
||||||
|
kwargs["unix_socket_path"] = EnvironmentSettings.REDIS_SOCKET
|
||||||
|
|
||||||
|
self.conn = redis.Redis(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
class RedisArchivist(RedisBase):
|
class RedisArchivist(RedisBase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user