caching-follows
All checks were successful
Deploy on push / deploy (push) Successful in 23s

This commit is contained in:
2024-02-26 04:58:27 +03:00
parent f40eff2822
commit 732bd2b098
2 changed files with 26 additions and 16 deletions

View File

@@ -29,22 +29,22 @@ async def update_follows_topics_cache(follows, author_id: int, ttl=25 * 60 * 60)
try:
payload = json.dumps(follows)
await redis.execute('SETEX', f'author:{author_id}:follows-topics', ttl, payload)
except Exception as exc:
logger.error(exc)
except Exception:
import traceback
traceback.print_exc()
exc = traceback.format_exc()
logger.error(exc)
async def update_follows_authors_cache(follows, author_id: int, ttl=25 * 60 * 60):
try:
payload = json.dumps(follows)
await redis.execute('SETEX', f'author:{author_id}:follows-authors', ttl, payload)
except Exception as exc:
logger.error(exc)
except Exception:
import traceback
traceback.print_exc()
exc = traceback.format_exc()
logger.error(exc)
@event.listens_for(Shout, 'after_insert')