Skip to content

Commit

Permalink
Cache alerts summary for 60 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Dec 5, 2024
1 parent 4d2feea commit 3d1cbc7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lvmapi/routers/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import warnings

import polars
from aiocache import Cache, cached
from aiocache.serializers import PickleSerializer
from fastapi import APIRouter, Request
from pydantic import BaseModel

Expand Down Expand Up @@ -43,6 +45,14 @@ class AlertsSummary(BaseModel):
@router.get("")
@router.get("/")
@router.get("/summary")
@cached(
ttl=60,
cache=Cache.REDIS, # type: ignore
key="alerts_summary",
serializer=PickleSerializer(),
port=6379,
namespace="lvmapi",
)
async def summary(request: Request) -> AlertsSummary:
"""Summary of alerts."""

Expand Down

0 comments on commit 3d1cbc7

Please sign in to comment.