Manager.OzCache¶
OzCache — generic device-side payload cache backed by Redis.
Lives inside the Manager package because the cache is a side-effect of publishing: Manager.sendData pushes to the cache on the way out. Any consumer on the device (ML, anomaly, QC, whatever) reads the same cache rather than re-hitting the cloud.
- Storage shape:
One Redis LIST per device: cache:{device_id}
Each element is a JSON-serialised copy of the payload that sendData received (the d dict — full telemetry for that tick).
LPUSH at the head, LTRIM to a fixed capacity computed from hours * 3600 / publish_interval_sec. No time-based rolling — oldest falls off when the list is full.
- Config (device-side, lives under self.config[“cache”]):
- {
“en”: 1, # enable / disable “hours”: 48, # retention window in hours “refill”: 1, # optional; cold-start via ppbanalytics “prefix”: “cache” # optional; key namespace
}
Attributes¶
Classes¶
Generic redis-backed rolling cache for outgoing device payloads. |
Functions¶
|
|
|
Spawn the refill daemon. Returns the thread handle, or None when the |
Module Contents¶
- Manager.OzCache.start_background_refill(cache: OzCache, manager, window_hours: int | None = None) threading.Thread | None[source]¶
Spawn the refill daemon. Returns the thread handle, or None when the cache/manager aren’t usable. Never blocks the caller.
- Manager.OzCache.DEFAULT_CONNECT_TIMEOUT = 2.0¶
- Manager.OzCache.REFILL_BACKOFF_SEC = (60, 120, 300, 900, 1800)¶
- Manager.OzCache.REFILL_BOOT_DELAY_SEC = 30¶
- Manager.OzCache.REFILL_MAX_PAGES = 10¶
- Manager.OzCache.REFILL_PAGE_LIMIT = 2000¶
- Manager.OzCache.REFILL_SKIP_SIZE = 500¶
- Manager.OzCache._REDIS_IMPORT_OK = True¶
- Manager.OzCache.context_logger¶