Coverage for session_buddy / tools / history_cache.py: 100.00%

7 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-04 00:43 -0800

1"""Caching layer for history analysis to improve performance. 

2 

3This module now uses ACB-backed cache for improved performance and 

4lifecycle management while maintaining backwards-compatible API. 

5""" 

6 

7from session_buddy.acb_cache_adapter import ACBHistoryCache, get_history_cache 

8 

9# Backwards-compatible alias 

10HistoryAnalysisCache = ACBHistoryCache 

11 

12 

13def get_cache(ttl: float = 300.0) -> ACBHistoryCache: 

14 """Get or create global cache instance. 

15 

16 Args: 

17 ttl: Time-to-live in seconds (default: 5 minutes) 

18 

19 Returns: 

20 Global cache instance using ACB-backed implementation 

21 

22 """ 

23 return get_history_cache(ttl=ttl) 

24 

25 

26async def reset_cache() -> None: 

27 """Reset global cache instance. 

28 

29 Useful for testing or clearing all cached data. 

30 """ 

31 from session_buddy.acb_cache_adapter import reset_caches 

32 

33 await reset_caches()