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:
|
if author_id:
|
||||||
cache_key = f'author:{author_id}'
|
cache_key = f'author:{author_id}'
|
||||||
cache = await redis.execute('GET', cache_key)
|
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
|
author_dict = None
|
||||||
if cache and isinstance(cache, str):
|
if cache and isinstance(cache, str):
|
||||||
|
logger.debug(f'got cached author {cache_key} -> {cache}')
|
||||||
author_dict = json.loads(cache)
|
author_dict = json.loads(cache)
|
||||||
else:
|
else:
|
||||||
result = await get_authors_with_stat_cached(q)
|
q = select(Author).where(Author.id == author_id)
|
||||||
if result:
|
[author] = await get_authors_with_stat_cached(q)
|
||||||
[author] = result
|
if author:
|
||||||
author_dict = author.dict()
|
author_dict = author.dict()
|
||||||
else:
|
else:
|
||||||
logger.warn('author was not cached!')
|
logger.warn('author was not cached!')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user