Cache

class Cache(val context: Context, ioQueue: CoroutineContext = Dispatchers.IO.limitedParallelism(1), json: Json) : CoroutineScope(source)

Two-layer key/value store: an in-memory map backed by one file per key.

  • The memory layer is updated synchronously and is authoritative once a key is in it. Deletes leave a Entry.Tombstone so a read can't reload a file whose deletion is still queued.

  • Disk writes and deletes run in order on the single-threaded ioQueue.

  • Files are written through AtomicFile, so a process kill mid-write leaves the previous value intact.

Constructors

Link copied to clipboard
constructor(context: Context, ioQueue: CoroutineContext = Dispatchers.IO.limitedParallelism(1), json: Json)

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
fun <T : Any> delete(storable: Storable<T>)
Link copied to clipboard
fun <T> read(storable: Storable<T>): T?
Link copied to clipboard
fun <T : Any> write(storable: Storable<T>, data: T)