FlowCache
internal class FlowCache<Key : Any, Value>(cacheScope: <Error class: unknown class>, flowTimeoutDuration: <Error class: unknown class> = FLOW_OBSERVING_TIMEOUT_IN_MILLIS.milliseconds)
In-memory cache for sharing flows. This aims to bundle all interested collectors and read from a single upstream source, reducing IO reading.
New collectors will get the latest value immediately. It converts produced flows into shared flows with a replay cache of 1.
Each individual call to get will get its own buffer (size of 1), and oldest values are dropped if the collector is slow.
Once the cached flows have no more collectors, the flows are removed from memory after flowTimeoutDuration.
Once the cacheScope is canceled, the whole cache stops.