diff --git a/kernelboard/api/leaderboard.py b/kernelboard/api/leaderboard.py index 42b3988..2cb6a20 100644 --- a/kernelboard/api/leaderboard.py +++ b/kernelboard/api/leaderboard.py @@ -1,4 +1,3 @@ -import time from typing import Any from flask import Blueprint from kernelboard.lib.db import get_db_connection @@ -9,18 +8,9 @@ leaderboard_bp = Blueprint("leaderboard_bp", __name__, url_prefix="/leaderboard") -# Simple in-memory cache keyed by leaderboard_id -_cache: dict[int, dict] = {} -CACHE_TTL_SECONDS = 60 - @leaderboard_bp.route("/", methods=["GET"]) def leaderboard(leaderboard_id: int): - now = time.time() - cached = _cache.get(leaderboard_id) - if cached is not None and (now - cached["timestamp"]) < CACHE_TTL_SECONDS: - return http_success(cached["data"]) - conn = get_db_connection() query = _get_query() with conn.cursor() as cur: @@ -37,9 +27,6 @@ def leaderboard(leaderboard_id: int): data = result[0] res = to_api_leaderboard_item(data) - - _cache[leaderboard_id] = {"data": res, "timestamp": now} - return http_success(res) diff --git a/kernelboard/api/leaderboard_summaries.py b/kernelboard/api/leaderboard_summaries.py index 9417d21..0144c39 100644 --- a/kernelboard/api/leaderboard_summaries.py +++ b/kernelboard/api/leaderboard_summaries.py @@ -1,5 +1,3 @@ -import time - from flask import Blueprint from datetime import datetime, timezone from kernelboard.lib.db import get_db_connection @@ -10,13 +8,6 @@ "leaderboard_summaries_bp", __name__, url_prefix="/leaderboard-summaries" ) -# Simple in-memory cache -_cache = { - "data": None, - "timestamp": 0, -} -CACHE_TTL_SECONDS = 60 - @leaderboard_summaries_bp.route("", methods=["GET"]) def index(): @@ -37,10 +28,6 @@ def index(): # ], # } - now = time.time() - if _cache["data"] is not None and (now - _cache["timestamp"]) < CACHE_TTL_SECONDS: - return http_success(_cache["data"]) - conn = get_db_connection() query = _get_query() with conn.cursor() as cur: @@ -51,12 +38,9 @@ def index(): if lb["gpu_types"] is None: lb["gpu_types"] = [] - result = {"leaderboards": leaderboards, "now": datetime.now(timezone.utc)} - - _cache["data"] = result - _cache["timestamp"] = now - - return http_success(result) + return http_success( + {"leaderboards": leaderboards, "now": datetime.now(timezone.utc)} + ) def _get_query():