InMemoryCache
An in-memory TimestampedCache with optional LRU eviction.
Mirrors SwiftyNetwork's InMemoryCache. State is guarded by a Mutex (the Kotlin analog of the Swift actor), and storage uses an access-ordered LinkedHashMap so reads promote entries to most-recently-used. When maxSize is set, the least-recently-used entries are evicted once the limit is exceeded.
Mutations are published to changes so reactive consumers can observe the cache; reads (which only reorder for LRU) do not emit.
Parameters
maximum number of entries to retain, or null for unbounded.
time source, injectable for deterministic tests.
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 entries older than maxAgeMillis relative to the current time.
Removes any value stored for key.