feat: version 0.9.30 - cache invalidation fixes

🔧 Fixed cache invalidation for featured materials:
- Enhanced invalidate_shout_related_cache with featured keys
- Fixed set_featured/set_unfeatured functions with async cache invalidation
- Materials now correctly appear/disappear from main page on feature/unfeature

 Code Quality: Python Standards Compliance
- Ruff linting & formatting checks passed
- MyPy type checking passed
- All functions have proper type hints and docstrings
- Tests passing successfully

Version bump: 0.9.30
This commit is contained in:
2025-10-02 22:31:13 +03:00
parent 3f263f35ef
commit 91a3189167
4 changed files with 40 additions and 1 deletions

10
cache/cache.py vendored
View File

@@ -513,6 +513,10 @@ async def invalidate_shout_related_cache(shout: Shout, author_id: int) -> None:
"unrated", # неоцененные
"recent", # последние
"coauthored", # совместные
# 🔧 Добавляем ключи с featured материалами
"featured", # featured публикации
"featured:recent", # недавние featured
"featured:top", # топ featured
}
# Добавляем ключи авторов
@@ -523,6 +527,12 @@ async def invalidate_shout_related_cache(shout: Shout, author_id: int) -> None:
cache_keys.update(f"topic_{t.id}" for t in shout.topics)
cache_keys.update(f"topic_shouts_{t.id}" for t in shout.topics)
# 🔧 Добавляем ключи featured материалов для каждой темы
for topic in shout.topics:
cache_keys.update(
[f"topic_{topic.id}:featured", f"topic_{topic.id}:featured:recent", f"topic_{topic.id}:featured:top"]
)
await invalidate_shouts_cache(list(cache_keys))