@@ -257,15 +257,15 @@ def get_cmds(
257
257
# Get current "now" time, which might be mocked via CXOTIME_NOW.
258
258
# get_cxotime_now() returns None if the env var is not set.
259
259
cxotime_now = get_cxotime_now ()
260
- now = CxoTime (cxotime_now )
261
260
262
261
# Cache key used for CMDS_RECENT and MATCHING_BLOCKS. These are all the relevant
263
262
# kwargs in update_archive_and_get_cmds_recent().
264
263
cache_key = scenario , cxotime_now , lookback , event_filter
264
+ logger .info (f"Cache key: { cache_key } " )
265
265
266
266
# For flight scenario or no internet or if the query stop time is guaranteed
267
267
# to not require recent commands then just use the archive.
268
- before_recent_cmds = stop < now - lookback * u .day
268
+ before_recent_cmds = stop < CxoTime ( cxotime_now ) - lookback * u .day
269
269
if scenario == "flight" or not HAS_INTERNET or before_recent_cmds :
270
270
cmds = IDX_CMDS
271
271
logger .info (
@@ -274,16 +274,21 @@ def get_cmds(
274
274
)
275
275
else :
276
276
if cache_key not in CMDS_RECENT :
277
+ logger .info (
278
+ "Recent commands not in cache: updating local cmd_events, loads "
279
+ "and getting recent commands"
280
+ )
277
281
cmds_recent = update_cmd_events_and_loads_and_get_cmds_recent (
278
282
scenario ,
279
283
lookback = lookback ,
280
284
stop_loads = cxotime_now ,
281
- cache = True ,
282
285
pars_dict = PARS_DICT ,
283
286
rev_pars_dict = REV_PARS_DICT ,
284
287
event_filter = event_filter ,
285
288
)
289
+ CMDS_RECENT [cache_key ] = cmds_recent
286
290
else :
291
+ logger .info ("Getting recent commands from cache" )
287
292
cmds_recent = CMDS_RECENT [cache_key ]
288
293
289
294
# Get `cmds` as correct mix of recent and archive commands that contains
@@ -361,7 +366,6 @@ def update_cmd_events_and_loads_and_get_cmds_recent(
361
366
* ,
362
367
lookback = None ,
363
368
stop_loads = None ,
364
- cache = True ,
365
369
pars_dict = None ,
366
370
rev_pars_dict = None ,
367
371
event_filter : Callable | list [Callable ] | None = None ,
@@ -536,10 +540,6 @@ def update_cmd_events_and_loads_and_get_cmds_recent(
536
540
cmds_recent = add_obs_cmds (cmds_recent , pars_dict , rev_pars_dict )
537
541
cmds_recent .meta ["loads_start" ] = start_cmds .date
538
542
539
- if cache :
540
- # Cache recent commands so future requests for the same scenario are fast
541
- CMDS_RECENT [scenario ] = cmds_recent
542
-
543
543
return cmds_recent
544
544
545
545
@@ -1428,7 +1428,6 @@ def _update_cmds_archive(lookback, stop_loads, match_prev_cmds, scenario, data_r
1428
1428
scenario = scenario ,
1429
1429
stop_loads = stop_loads ,
1430
1430
lookback = lookback ,
1431
- cache = False ,
1432
1431
pars_dict = pars_dict ,
1433
1432
)
1434
1433
0 commit comments