This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
from fastapi import APIRouter, HTTPException, Header
|
||||
from typing import Optional
|
||||
from app.config import API_KEY
|
||||
from app.services.cache import clear_cache, get_cache_stats
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/cache/clear")
|
||||
async def clear_cache_route(x_api_key: Optional[str] = Header(None)):
|
||||
"""Clear the entire cache database"""
|
||||
# Validate API key
|
||||
if not x_api_key or x_api_key != API_KEY:
|
||||
raise HTTPException(status_code=401, detail="Invalid API key")
|
||||
|
||||
return clear_cache()
|
||||
|
||||
@router.get("/cache/stats")
|
||||
async def cache_stats_route(x_api_key: Optional[str] = Header(None)):
|
||||
"""Get cache statistics"""
|
||||
# Validate API key
|
||||
if not x_api_key or x_api_key != API_KEY:
|
||||
raise HTTPException(status_code=401, detail="Invalid API key")
|
||||
|
||||
return get_cache_stats()
|
||||
Reference in New Issue
Block a user