Refactor of caching & data storage part 1

This commit is contained in:
Ian Renton
2026-07-31 14:12:55 +01:00
parent 266468f938
commit d26ddff7d1
17 changed files with 277 additions and 253 deletions
+3 -3
View File
@@ -3,7 +3,7 @@ from datetime import datetime
import pytz
from core.cache_utils import SEMI_STATIC_URL_DATA_CACHE
from core.url_data_cache import URL_DATA_CACHE
from core.constants import HTTP_HEADERS
from data.sig_ref import SIGRef
from data.spot import Spot
@@ -56,8 +56,8 @@ class GMA(HTTPSpotProvider):
# GMA doesn't give what programme (SIG) the reference is for until we separately look it up.
if "REF" in source_spot:
try:
ref_response = SEMI_STATIC_URL_DATA_CACHE.get(self.REF_INFO_URL_ROOT + source_spot["REF"],
headers=HTTP_HEADERS)
ref_response = URL_DATA_CACHE.get(self.REF_INFO_URL_ROOT + source_spot["REF"],
headers=HTTP_HEADERS)
# Sometimes this is blank even if it's a 200 response, so handle that
if ref_response.ok and ref_response.text is not None and ref_response.text != "":
ref_info = ref_response.json()
+1 -1
View File
@@ -59,7 +59,7 @@ class SpotProvider:
def _add_spot(self, spot):
if not spot.expired():
self._spots.add(spot.id, spot, expire=MAX_SPOT_AGE)
self._spots.set(spot.id, spot)
# Ping the web server in case we have any SSE connections that need to see this immediately
if self._web_server:
self._web_server.notify_new_spot(spot)