Get cache statistics. Returns: Dictionary with cache stats
(self)
| 254 | logger.info(f"Removed {removed} expired cache entries") |
| 255 | |
| 256 | return removed |
| 257 | |
| 258 | def get_stats(self) -> dict: |
| 259 | """Get cache statistics. |
| 260 | |
| 261 | Returns: |
| 262 | Dictionary with cache stats |
| 263 | """ |
| 264 | memory_entries = len(self._memory_cache) |
| 265 | |
| 266 | disk_entries = 0 |
| 267 | try: |
| 268 | disk_entries = len(list(self.cache_dir.glob("*.json"))) |
| 269 | except Exception as e: |
| 270 | logger.error(f"Error counting disk cache: {e}") |
| 271 | |
| 272 | total_entries = max(memory_entries, disk_entries) |
| 273 | |
| 274 | return { |
| 275 | "memory_entries": memory_entries, |
| 276 | "disk_entries": disk_entries, |
| 277 | "total_entries": total_entries, |
| 278 | "cache_directory": str(self.cache_dir), |
| 279 | "ttl_seconds": self.ttl, |
| 280 | } |
| 281 |
no outgoing calls