Skip to content

Commit bcb7f42

Browse files
committed
Default DSN use LRU cache for optimization and to make warning come up only once
1 parent 437615d commit bcb7f42

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sample_fastapi/app/database/config.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from functools import lru_cache
23

34
from pydantic import Field
45

@@ -9,8 +10,11 @@
910
APP_DB_SESSION_MANAGER_KEY = "_dbsm" # Lol
1011

1112

13+
@lru_cache()
1214
def _default_db_dsn():
13-
LOG.warning("Using SQLite In-memory database as `database_url` config was not specified. Content WILL be lost after shutting down the app!")
15+
LOG.warning(
16+
"Using SQLite In-memory database as `database_url` config was not specified. Content WILL be lost after shutting down the app!"
17+
)
1418
return "sqlite+aiosqlite:///:memory:"
1519

1620

0 commit comments

Comments
 (0)