Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 55e2b8f

Browse files
committed
chore(cache): increase cache duration for station data
setting the cache to 1 hour seems like a good balance between performance and data freshness.
1 parent ef4622c commit 55e2b8f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

pems_data/src/pems_data/services/stations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def get_district_metadata(self, district_number: str) -> pd.DataFrame:
4343
def get_imputed_agg_5min(self, station_id: str) -> pd.DataFrame:
4444
"""Loads imputed aggregate 5 minute data for a specific station."""
4545

46-
cache_opts = {"key": self._build_cache_key("imputed", "agg", "5m", "station", station_id), "ttl": 300} # 5 minutes
46+
cache_opts = {"key": self._build_cache_key("imputed", "agg", "5m", "station", station_id), "ttl": 3600} # 1 hour
4747
columns = [
4848
"STATION_ID",
4949
"LANE",

pems_streamlit/src/pems_streamlit/apps/districts/app_stations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def match(m: re.Match):
3434
return S3.get_prefixes(pattern, initial_prefix=STATIONS.imputation_detector_agg_5min, match_func=match)
3535

3636

37-
@st.cache_data(ttl=300) # Cache for 5 minutes
37+
@st.cache_data(ttl=3600) # Cache for 1 hour
3838
def load_station_data(station_id: str) -> pd.DataFrame:
3939
"""
4040
Loads station data for a specific station.

tests/pytest/pems_data/services/test_stations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ def test_get_imputed_agg_5min(self, service: StationsService, data_source: IData
7474

7575
cache_opts = data_source.read.call_args.kwargs["cache_opts"]
7676
assert station_id in cache_opts["key"]
77-
assert cache_opts["ttl"] == 300
77+
assert cache_opts["ttl"] == 3600
7878

7979
pd.testing.assert_frame_equal(result, df)

0 commit comments

Comments
 (0)