FileSystemCache
A durable PersistentCache that stores each entry as a file under directory.
Mirrors SwiftyNetwork's disk-backed cache. Values are turned into text by the caller-supplied encode/decode pair (e.g. kotlinx.serialization's Json.encodeToString/decodeFromString), so :cache stays free of any serialization dependency. Each file stores the epoch-millisecond timestamp on its first line followed by the encoded value, so it is a TimestampedCache and promotes into a memory layer without losing age (see LayeredCache).
File I/O runs on ioContext and is guarded by a Mutex. Writes use a same-directory temporary file and atomic replacement, so a process interruption leaves either the old complete entry or the new complete entry. Only files this cache wrote (suffixed SUFFIX) are touched, so the directory may be shared. A malformed or unreadable file reads back as null rather than throwing.
Parameters
the storage directory; created on first write.
serializes a value to text.
parses text produced by encode back into a value.
context for blocking file I/O; defaults to Dispatchers.IO.
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 any value stored for key.