This commit is contained in:
parent
8635fd9c08
commit
5478ff45e7
|
@ -49,13 +49,13 @@ async def get_author(_, _info, slug='', author_id=None):
|
||||||
|
|
||||||
if author_id:
|
if author_id:
|
||||||
cache = await redis.execute('GET', f'id:{author_id}:author')
|
cache = await redis.execute('GET', f'id:{author_id}:author')
|
||||||
author = json.loads(cache)
|
author = json.loads(cache) if cache else get_with_stat(select(Author).where(Author.id == author_id)).first()
|
||||||
if not author:
|
|
||||||
q = select(Author).where(Author.id == author_id)
|
|
||||||
[author] = get_with_stat(q)
|
|
||||||
if author:
|
if author:
|
||||||
await update_author_cache(author.dict())
|
await update_author_cache(author.dict())
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
traceback.print_exc()
|
||||||
logger.error(exc)
|
logger.error(exc)
|
||||||
return author
|
return author
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user