LayeredCache
A two-tier cache composing a fast memory layer over an optional persistent layer.
Mirrors SwiftyNetwork's LayeredCache: reads consult memory first, fall back to the persistent layer, and promote a persistent hit back into memory — preserving the original timestamp when the memory layer is a TimestampedCache. Writes go through to both layers.
changes reflects writes and removals against this layered view; read-time promotions are not reported, since the logical value did not change. A write can also evict other keys from the backing caches, so observers must re-read their keys on every notification from this view.
Operations through this instance are serialized across both tiers, so a slow disk read cannot promote stale data over a newer write or resurrect a removed entry. Access the backing caches through this instance to retain that guarantee; independently mutating them bypasses its lock.
Parameters
the fast, volatile layer.
the durable layer, or null for a memory-only cache.
Functions
A hot stream of CacheChanges for this cache. The default is an empty flow, so caches that cannot observe mutations are simply non-reactive; observable caches override this.
Removes any value stored for key.