feat(cache): Add thread-safe Redis client and enable activity stats cache
- Add get_thread_safe_redis() function with thread-local storage and PID checking to prevent "Future attached to a different loop" errors in Celery thread and prefork pools - Implement health_check_interval=30 to prevent stale connection errors after fork - Uncomment and enable ActivityStatsCache module in cache/memory/__init__.py - Uncomment ActivityStatsCache implementation in activity_stats_cache.py and update to use get_thread_safe_redis() - Update interest_memory.py to use thread-safe Redis client - Update write_tools.py to use thread-safe Redis client - Remove redundant Chinese comments from aioRedis.py for cleaner code - Ensures safe Redis operations across different execution contexts and Celery worker configurations
This commit is contained in:
4
api/app/cache/memory/__init__.py
vendored
4
api/app/cache/memory/__init__.py
vendored
@@ -4,9 +4,9 @@ Memory 缓存模块
|
||||
提供记忆系统相关的缓存功能
|
||||
"""
|
||||
from .interest_memory import InterestMemoryCache
|
||||
# from .activity_stats_cache import ActivityStatsCache
|
||||
from .activity_stats_cache import ActivityStatsCache
|
||||
|
||||
__all__ = [
|
||||
"InterestMemoryCache",
|
||||
# "ActivityStatsCache",
|
||||
"ActivityStatsCache",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user