add Unix socket support for redis-host=

This commit is contained in:
Julien Moutinho 2021-12-04 18:23:09 +01:00 committed by Drew DeVault
parent 72844929ea
commit 41a5a559e8
1 changed files with 2 additions and 9 deletions

View File

@ -1,11 +1,4 @@
from redis import Redis
from redis import from_url
from srht.config import cfg
from urllib.parse import urlparse
url = cfg("sr.ht", "redis-host", "redis://localhost")
url = urlparse(url)
redis = Redis(host=url.hostname,
port=(url.port or 6379),
password=url.password,
db=int(url.path[1:]) if url.path else 0)
redis = from_url(cfg("sr.ht", "redis-host", "redis://localhost"))