DivYonko commited on
Commit ·
c5b07c4
1
Parent(s): 8a6fade
fix: remove cache from load_stream_data so in-memory store is always read fresh
Browse files
app.py
CHANGED
|
@@ -260,8 +260,6 @@ def start_scraper(slot_idx: int, video_id: str, redis_key: str) -> None:
|
|
| 260 |
_SCRAPER_STOP[key] = stop_event
|
| 261 |
_SCRAPER_THREADS[key] = t
|
| 262 |
t.start()
|
| 263 |
-
# Clear the data cache so the UI picks up new messages immediately
|
| 264 |
-
load_stream_data.clear()
|
| 265 |
|
| 266 |
|
| 267 |
def stop_scraper(slot_idx: int) -> None:
|
|
@@ -520,10 +518,8 @@ def csv_download(df_export, label, filename):
|
|
| 520 |
file_name=filename, mime="text/csv", key=filename)
|
| 521 |
|
| 522 |
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
"""Load and parse messages from the in-memory store. Cached for 2s.
|
| 526 |
-
_store_len is used as a cache-busting parameter — changes when new data arrives."""
|
| 527 |
if limit:
|
| 528 |
raws = store_lrange(redis_key, -limit, -1)
|
| 529 |
else:
|
|
@@ -892,7 +888,7 @@ st.divider()
|
|
| 892 |
# Use stream A's redis_key (session state is the source of truth)
|
| 893 |
_primary_key = st.session_state.streams[0]["redis_key"]
|
| 894 |
_current_len = store_llen(_primary_key)
|
| 895 |
-
all_data = load_stream_data(_primary_key
|
| 896 |
data = all_data[-msg_limit:] if len(all_data) > msg_limit else all_data
|
| 897 |
|
| 898 |
if not all_data:
|
|
@@ -1414,7 +1410,7 @@ if len(active_streams) > 1:
|
|
| 1414 |
sidx = st.session_state.streams.index(stream)
|
| 1415 |
color = STREAM_COLORS[sidx]
|
| 1416 |
slabel = STREAM_NAMES[sidx]
|
| 1417 |
-
s_data = load_stream_data(stream["redis_key"]
|
| 1418 |
if not s_data:
|
| 1419 |
col.info(f"No data yet for Stream {slabel}")
|
| 1420 |
continue
|
|
@@ -1443,7 +1439,7 @@ if len(active_streams) > 1:
|
|
| 1443 |
sidx = st.session_state.streams.index(stream)
|
| 1444 |
color = STREAM_COLORS[sidx]
|
| 1445 |
slabel = STREAM_NAMES[sidx]
|
| 1446 |
-
s_data = load_stream_data(stream["redis_key"]
|
| 1447 |
if not s_data:
|
| 1448 |
continue
|
| 1449 |
s_df = pd.DataFrame(s_data)
|
|
|
|
| 260 |
_SCRAPER_STOP[key] = stop_event
|
| 261 |
_SCRAPER_THREADS[key] = t
|
| 262 |
t.start()
|
|
|
|
|
|
|
| 263 |
|
| 264 |
|
| 265 |
def stop_scraper(slot_idx: int) -> None:
|
|
|
|
| 518 |
file_name=filename, mime="text/csv", key=filename)
|
| 519 |
|
| 520 |
|
| 521 |
+
def load_stream_data(redis_key: str, limit: int | None = None):
|
| 522 |
+
"""Load and parse messages from the in-memory store (no cache — store is in-memory)."""
|
|
|
|
|
|
|
| 523 |
if limit:
|
| 524 |
raws = store_lrange(redis_key, -limit, -1)
|
| 525 |
else:
|
|
|
|
| 888 |
# Use stream A's redis_key (session state is the source of truth)
|
| 889 |
_primary_key = st.session_state.streams[0]["redis_key"]
|
| 890 |
_current_len = store_llen(_primary_key)
|
| 891 |
+
all_data = load_stream_data(_primary_key)
|
| 892 |
data = all_data[-msg_limit:] if len(all_data) > msg_limit else all_data
|
| 893 |
|
| 894 |
if not all_data:
|
|
|
|
| 1410 |
sidx = st.session_state.streams.index(stream)
|
| 1411 |
color = STREAM_COLORS[sidx]
|
| 1412 |
slabel = STREAM_NAMES[sidx]
|
| 1413 |
+
s_data = load_stream_data(stream["redis_key"])
|
| 1414 |
if not s_data:
|
| 1415 |
col.info(f"No data yet for Stream {slabel}")
|
| 1416 |
continue
|
|
|
|
| 1439 |
sidx = st.session_state.streams.index(stream)
|
| 1440 |
color = STREAM_COLORS[sidx]
|
| 1441 |
slabel = STREAM_NAMES[sidx]
|
| 1442 |
+
s_data = load_stream_data(stream["redis_key"])
|
| 1443 |
if not s_data:
|
| 1444 |
continue
|
| 1445 |
s_df = pd.DataFrame(s_data)
|