Refactor of caching & data storage part 14 #118

This commit is contained in:
Ian Renton
2026-08-03 19:25:25 +01:00
parent 50ab27e4a2
commit f82d611b7e
15 changed files with 144 additions and 142 deletions
@@ -15,6 +15,7 @@ class CallsignDataProvider:
self.name = name
self.enabled = provider_config["enabled"]
self.priority = int(provider_config["priority"])
self.last_update_time = datetime.min.replace(tzinfo=pytz.UTC)
self.status = "Not Started" if self.enabled else "Disabled"
self._storage = storage
@@ -38,13 +39,16 @@ class CallsignDataProvider:
possible. Data is cached internally for a set period of 30 days to avoid the need to request data from servers
each time."""
if callsign in self._storage:
return self._storage[callsign]
if self.enabled:
if callsign in self._storage:
return self._storage[callsign]
else:
c = self._perform_new_lookup(callsign, lookup_credentials)
if c:
self._storage.set(callsign, c, expire=DATA_STORE.CALLSIGN_DATA_TTL_SEC)
return c
else:
c = self._perform_new_lookup(callsign, lookup_credentials)
if c:
self._storage.set(callsign, c, expire=DATA_STORE.CALLSIGN_DATA_TTL_SEC)
return c
return None
def _perform_new_lookup(self, callsign, lookup_credentials):