Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /dchrnv_neurograph /src /api /routers /cache_stats.py
| """ | |
| Cache statistics endpoint. | |
| Provides cache performance metrics and management. | |
| """ | |
| from fastapi import APIRouter, Depends, status | |
| from ..models.response import SuccessResponse | |
| from ..auth.dependencies import get_current_active_user | |
| from ..cache import get_all_cache_stats, cleanup_all_caches | |
| from ..models.auth import User | |
| from ..logging_config import get_logger | |
| router = APIRouter( | |
| prefix="/cache", | |
| tags=["cache"], | |
| ) | |
| logger = get_logger(__name__, component="cache") | |
| async def get_cache_stats_endpoint( | |
| user: User = Depends(get_current_active_user) | |
| ) -> SuccessResponse: | |
| """ | |
| Get cache statistics. | |
| Returns statistics for all cache instances: | |
| - Size and max_size | |
| - Hit/miss counts | |
| - Hit rate percentage | |
| - Eviction count | |
| **Requires:** admin:config permission | |
| """ | |
| stats = get_all_cache_stats() | |
| return SuccessResponse( | |
| message="Cache statistics retrieved", | |
| data=stats | |
| ) | |
| async def cleanup_caches_endpoint( | |
| user: User = Depends(get_current_active_user) | |
| ) -> SuccessResponse: | |
| """ | |
| Cleanup expired cache entries. | |
| Removes all expired entries from all cache instances | |
| to free up memory. | |
| **Requires:** admin:config permission | |
| """ | |
| logger.info("Cache cleanup initiated", extra={"user": user.username}) | |
| cleanup_all_caches() | |
| stats = get_all_cache_stats() | |
| logger.info("Cache cleanup completed", extra={"stats": stats}) | |
| return SuccessResponse( | |
| message="Cache cleanup completed", | |
| data=stats | |
| ) | |
Xet Storage Details
- Size:
- 1.99 kB
- Xet hash:
- 693e31246a3c38c4549761c7bb33a9d2603ff6fe399e6eca2732ea399a31fa35
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.