This commit is contained in:
parent
e103b283cb
commit
8826af02b5
|
@ -63,15 +63,14 @@ async def get_author(_, _info, slug='', author_id=None):
|
|||
if author_id:
|
||||
cache_key = f'author:{author_id}'
|
||||
cache = await redis.execute('GET', cache_key)
|
||||
logger.debug(f'GET {cache_key} -> {cache}')
|
||||
q = select(Author).where(Author.id == author_id)
|
||||
author_dict = None
|
||||
if cache and isinstance(cache, str):
|
||||
logger.debug(f'got cached author {cache_key} -> {cache}')
|
||||
author_dict = json.loads(cache)
|
||||
else:
|
||||
result = await get_authors_with_stat_cached(q)
|
||||
if result:
|
||||
[author] = result
|
||||
q = select(Author).where(Author.id == author_id)
|
||||
[author] = await get_authors_with_stat_cached(q)
|
||||
if author:
|
||||
author_dict = author.dict()
|
||||
else:
|
||||
logger.warn('author was not cached!')
|
||||
|
|
Loading…
Reference in New Issue
Block a user