From c9733ece24a56a3e1627ba09c419851e3da9bb8e Mon Sep 17 00:00:00 2001 From: Untone Date: Sat, 30 Aug 2025 21:38:27 +0300 Subject: [PATCH] following --- cache/cache.py | 1 + resolvers/follower.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/cache/cache.py b/cache/cache.py index d1f6b279..9074bd15 100644 --- a/cache/cache.py +++ b/cache/cache.py @@ -318,6 +318,7 @@ async def get_cached_follower_authors(author_id: int): logger.debug(f"[get_cached_follower_authors] Cache HIT for {cache_key}: {len(authors_ids)} authors") else: logger.debug(f"[get_cached_follower_authors] Cache MISS for {cache_key}, querying DB") + logger.info("[get_cached_follower_authors] Cache MISS - this should happen after follow/unfollow operations") # Query authors from database with local_session() as session: authors_ids = [ diff --git a/resolvers/follower.py b/resolvers/follower.py index 2a448191..6863af50 100644 --- a/resolvers/follower.py +++ b/resolvers/follower.py @@ -129,6 +129,11 @@ async def follow( logger.debug("Обновление кэша сущности") await cache_method(entity_dict) + # Инвалидируем кэш подписок пользователя для обновления списка подписок + cache_key_pattern = f"author:follows-{entity_type}s:{follower_id}" + await redis.execute("DEL", cache_key_pattern) + logger.debug(f"Инвалидирован кэш подписок: {cache_key_pattern}") + if what == "AUTHOR" and not existing_sub: logger.debug("Отправка уведомления автору о подписке") if isinstance(follower_dict, dict) and isinstance(entity_id, int):