mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 02:21:42 +00:00
Refactor of caching & data storage part 6 #118
This commit is contained in:
+9
-4
@@ -22,6 +22,7 @@ class DataStore:
|
||||
self.alerts = None
|
||||
self.spots = None
|
||||
self.callsigns = None
|
||||
self.dxcc_data = None
|
||||
self.sigrefs = None
|
||||
self.status_data = None
|
||||
self._status = None
|
||||
@@ -42,10 +43,13 @@ class DataStore:
|
||||
self._status.add("status_data", {})
|
||||
self.status_data = self._status.get("status_data")
|
||||
|
||||
# Standard disk cache for SIG ref data. Separate provider threads will repopulate theis on a regular basis
|
||||
# but there's no need for a TTL since old data is better than no data. We need to key on both SIG and reference,
|
||||
# and trying to do two layers of dict in diskcache absolutely destroys performance with unpickling huge dicts,
|
||||
# so we have an ugly "SIG:ref" syntax for keys to keep it a single level.
|
||||
# Standard disk cache for static reference and SIG ref data. Separate provider threads will repopulate these on
|
||||
# a regular basis but there's no need for a TTL since old data is better than no data.
|
||||
self.dxcc_data = diskcache.Cache(CACHE_DIR + "dxcc_data")
|
||||
|
||||
# For SIG reference data specifically, we need to key on both SIG *and* reference, and trying to do two layers
|
||||
# of dict in diskcache absolutely destroys performance with unpickling huge dicts, so we have an ugly "SIG:ref"
|
||||
# syntax for keys to keep it a single level.
|
||||
self.sigrefs = diskcache.Cache(CACHE_DIR + "sigrefs")
|
||||
logging.info(f"Loaded data for %d SIG references.", len(self.sigrefs))
|
||||
|
||||
@@ -73,6 +77,7 @@ class DataStore:
|
||||
self.alerts.close()
|
||||
self._solar.close()
|
||||
self._status.close()
|
||||
self.dxcc_data.close()
|
||||
self.sigrefs.close()
|
||||
self.callsigns.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user