cache-author-fiz

This commit is contained in:
Untone 2024-08-14 16:30:52 +03:00
parent 8f3fded5fe
commit 4c126fd859

5
cache/cache.py vendored
View File

@ -72,8 +72,9 @@ async def get_cached_author(author_id: int, get_with_stat):
return json.loads(result)
# Load from database if not found in cache
q = select(Author).where(Author.id == author_id)
author = get_with_stat(q)
if author:
authors = get_with_stat(q)
if authors:
author = authors[0]
await cache_author(author.dict())
return author.dict()
return None