cache-reform

This commit is contained in:
2024-03-12 15:50:57 +03:00
parent d1a510b093
commit 9b7aa57a18
5 changed files with 50 additions and 30 deletions

View File

@@ -22,8 +22,13 @@ DEFAULT_FOLLOWS = {
async def set_author_cache(author: dict):
payload = json.dumps(author, cls=CustomJSONEncoder)
await redis.execute("SET", f'user:{author.get("user")}:author', payload)
await redis.execute("SET", f'id:{author.get("id")}:author', payload)
await redis.execute("SET", f'user:{author.get("user")}', payload)
await redis.execute("SET", f'author:{author.get("id")}', payload)
async def set_topic_cache(topic: dict):
payload = json.dumps(topic, cls=CustomJSONEncoder)
await redis.execute("SET", f'topic:{topic.get("id")}', payload)
async def update_author_followers_cache(author_id: int, followers):