Skip to content

Commit 0b22d3a

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 36fd709 commit 0b22d3a

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
@@ -80,7 +80,7 @@ def get_imputed_agg_5min(self, station_id: str) -> pd.DataFrame:
8080
value (pandas.DataFrame): The station's data as a DataFrame.
8181
"""
8282

83-
cache_opts = {"key": self._build_cache_key("imputed", "agg", "5m", "station", station_id), "ttl": 300} # 5 minutes
83+
cache_opts = {"key": self._build_cache_key("imputed", "agg", "5m", "station", station_id), "ttl": 3600} # 1 hour
8484
columns = [
8585
"STATION_ID",
8686
"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)