Buckets:

download
raw
1.39 kB
"""Cache management API endpoints."""
from __future__ import annotations
from fastapi import APIRouter, Depends
from pydantic import BaseModel
from malwar.api.rbac import require_config_manage
router = APIRouter()
class CacheClearResponse(BaseModel):
cleared: int
message: str
class CacheStatsResponse(BaseModel):
hits: int
misses: int
total: int
hit_rate: float
size: int
@router.post("/cache/clear", response_model=CacheClearResponse)
async def clear_cache(
_auth: object = Depends(require_config_manage),
) -> CacheClearResponse:
"""Flush the scan result cache (admin only)."""
from malwar.cache.manager import get_cache_manager
mgr = get_cache_manager()
count = await mgr.clear()
return CacheClearResponse(cleared=count, message=f"Cleared {count} cached entries")
@router.get("/cache/stats", response_model=CacheStatsResponse)
async def cache_stats(
_auth: object = Depends(require_config_manage),
) -> CacheStatsResponse:
"""Show cache hit/miss statistics and current size."""
from malwar.cache.manager import get_cache_manager
mgr = get_cache_manager()
stats = mgr.stats
current_size = await mgr.size()
return CacheStatsResponse(
hits=stats.hits,
misses=stats.misses,
total=stats.total,
hit_rate=round(stats.hit_rate, 4),
size=current_size,
)

Xet Storage Details

Size:
1.39 kB
·
Xet hash:
acaf1a9c3b9f1bfb0a32ea46eb2a7d49f5d9b2da24654991143b637534e0fe53

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.