OzWrapper.OzAnomaly.data_provider.OzCacheProvider¶
- class OzWrapper.OzAnomaly.data_provider.OzCacheProvider(cache: OzCache | None)¶
Bases:
digraph inheritancef363e48165 { bgcolor=transparent; rankdir=TB; ratio=compress; size="8.0, 6.0"; "ABC" [URL="https://docs.python.org/3/library/abc.html#abc.ABC",fillcolor="#e8f4f8",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="filled,rounded",target="_top",tooltip="Helper class that provides a standard way to create an ABC using"]; "DataProvider" [URL="DataProvider.html#OzWrapper.OzAnomaly.data_provider.DataProvider",fillcolor="#e8f4f8",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="filled,rounded",target="_top",tooltip="Supplies recent sensor data to the anomaly detector."]; "ABC" -> "DataProvider" [arrowhead=empty,arrowsize=0.8,style="setlinewidth(0.5)"]; "OzCacheProvider" [URL="OzCacheProvider.html#OzWrapper.OzAnomaly.data_provider.OzCacheProvider",fillcolor="#e8f4f8",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="filled,rounded",target="_top",tooltip="Read recent sensor payloads from the Manager-owned :class:`OzCache`."]; "DataProvider" -> "OzCacheProvider" [arrowhead=empty,arrowsize=0.8,style="setlinewidth(0.5)"]; }DataProviderRead recent sensor payloads from the Manager-owned
OzCache.OzCache is a Redis-backed rolling list of the same
datadicts thatManager.sendDatapublishes to the gateway. The cache is populated by two paths:Live ticks — every successful publish writes its payload to Redis (
Manager.sendDatacallsself.cache.push(payload)before the HTTP POST).Cold-start refill —
OzCache.refill()paginates through the gateway’s/ppb/device/endpoint at boot to seed the cache before live ticks have caught up.
OzCache normalises every payload’s
tfield to milliseconds — live ticks are already ms (lastPublishMillis), and refilled PPB rows (which arrive in seconds) are multiplied by 1000 insideOzCache.refill. So this provider can apply a single ms-based cutoff without inspecting where each row came from.Args: cache: The
OzCacheinstance owned byManager(typicallymanager.cache). May beNoneor unconfigured —get_window()handles both and returnsNone.- get_window(hours: int) Window | None¶
Return the last
hoursof cached payloads as a column dict.Returns
Nonewhen the cache is unavailable, empty, or holds no records inside the requested window.
- __slots__ = ()¶
- cache¶