author:user-key
All checks were successful
Deploy on push / deploy (push) Successful in 49s

This commit is contained in:
Untone 2024-05-30 18:07:41 +03:00
parent d20647c825
commit 3712ecf8ae

View File

@ -28,7 +28,7 @@ async def cache_author(author: dict):
author_id = author.get("id") author_id = author.get("id")
user_id = author.get("user") user_id = author.get("user")
payload = json.dumps(author, cls=CustomJSONEncoder) payload = json.dumps(author, cls=CustomJSONEncoder)
await redis.execute("SET", f"user:id:{user_id}", author_id) await redis.execute("SET", f"author:user:{user_id}", author_id)
await redis.execute("SET", f"author:id:{author_id}", payload) await redis.execute("SET", f"author:id:{author_id}", payload)
@ -74,7 +74,7 @@ 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): async def get_cached_author_by_user_id(user_id: str, get_with_stat):
author_id = await redis.execute("GET", f"user:id:{user_id}") author_id = await redis.execute("GET", f"author:user:{user_id}")
if author_id: if author_id:
return await get_cached_author(int(author_id), get_with_stat) return await get_cached_author(int(author_id), get_with_stat)