Cache built-in game parsing to avoid recomputation per request
This commit is contained in:
parent
0a7cdc0f15
commit
46955f0644
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "chess-pressure"
|
name = "chess-pressure"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
description = "Chess pressure heatmap visualization"
|
description = "Chess pressure heatmap visualization"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from functools import lru_cache
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
@ -39,6 +40,7 @@ def list_games():
|
|||||||
|
|
||||||
|
|
||||||
@app.get("/api/games/{game_id}")
|
@app.get("/api/games/{game_id}")
|
||||||
|
@lru_cache(maxsize=16)
|
||||||
def load_game(game_id: str):
|
def load_game(game_id: str):
|
||||||
pgn = get_game_pgn(game_id)
|
pgn = get_game_pgn(game_id)
|
||||||
if pgn is None:
|
if pgn is None:
|
||||||
|
|||||||
2
uv.lock
generated
2
uv.lock
generated
@ -41,7 +41,7 @@ sdist = { url = "https://files.pythonhosted.org/packages/93/09/7d04d7581ae3bb8b5
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chess-pressure"
|
name = "chess-pressure"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "fastapi" },
|
{ name = "fastapi" },
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user