FileKache

A persistent coroutine-safe ContainerKache implementation that uses Okio to store files under the hood and exposes a simple path-based API.

It uses a journal file to keep track of the cache state and to ensure that the cache is always in a consistent state.

It can be built using the following syntax:

val cache = OkioFileKache(directoryPath = "cache", maxSize = 100L * 1024L * 1024L) {
strategy = KacheStrategy.LRU
// ...
}

See also

Types

Link copied to clipboard
class Configuration(var directoryPath: String, var maxSize: Long)

Configuration for FileKache. It is used as a receiver of FileKache builder which is invoke.

Properties

Link copied to clipboard
open override val maxSize: Long
Link copied to clipboard
open override val size: Long

Functions

Link copied to clipboard
open suspend override fun clear()
Link copied to clipboard
open suspend override fun close()
Link copied to clipboard
open suspend override fun get(key: String): String?
Link copied to clipboard
open suspend override fun getAllKeys(): KacheKeys<String>
Link copied to clipboard
open suspend override fun getIfAvailable(key: String): String?
Link copied to clipboard
open suspend override fun getKeys(): Set<String>
Link copied to clipboard
open suspend override fun getOrPut(key: String, creationFunction: suspend (String) -> Boolean): String?
Link copied to clipboard
open suspend override fun getUnderCreationKeys(): Set<String>
Link copied to clipboard
open suspend override fun put(key: String, creationFunction: suspend (String) -> Boolean): String?
Link copied to clipboard
open suspend override fun putAsync(key: String, creationFunction: suspend (String) -> Boolean): Deferred<String?>
Link copied to clipboard
open suspend override fun remove(key: String)
Link copied to clipboard
open suspend override fun removeAllUnderCreation()
Link copied to clipboard
open suspend override fun resize(maxSize: Long)
Link copied to clipboard
open suspend override fun trimToSize(size: Long)