From d3fe4c4aff449d4ed5f1004434cd2e2a0fd2b7d5 Mon Sep 17 00:00:00 2001 From: Untone Date: Wed, 5 Jun 2024 18:48:41 +0300 Subject: [PATCH] get_cached_author-fix-2 --- services/cache.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/cache.py b/services/cache.py index d68f36b7..7f516bd0 100644 --- a/services/cache.py +++ b/services/cache.py @@ -76,12 +76,13 @@ async def get_cached_author(author_id: int, get_with_stat): async def get_cached_author_by_user_id(user_id: str, get_with_stat): - author_dict = await redis.execute("GET", f"author:user:{user_id}") + author_str = await redis.execute("GET", f"author:user:{user_id}") author_id = None - if not author_dict: + if not author_str: with local_session() as session: author_id = session.query(Author.id).filter(Author.user == user_id).first() else: + author_dict = json.loads(author_str) author_id = author_dict.get("id") if author_id: cached_author = await get_cached_author(int(author_id), get_with_stat)