MongoKacheController

class MongoKacheController(cacheEnabled: () -> Boolean = { true }, cache: CacheClient, asyncWriteScope: CoroutineScope? = null, onAsyncWriteError: (Throwable) -> Unit = {}) : KacheController

MongoDB adapter providing a typed public API over KacheController.

Each method delegates to KacheController's internal helpers, deriving cache keys from the database and collection names in the MongoCollection namespace.

Constructors

Link copied to clipboard
constructor(cacheEnabled: () -> Boolean = { true }, cache: CacheClient, asyncWriteScope: CoroutineScope? = null, onAsyncWriteError: (Throwable) -> Unit = {})

Properties

Link copied to clipboard

Functions

Link copied to clipboard
suspend fun <T : Model> get(id: String, collection: MongoCollection<T>, serializer: KSerializer<T>, expire: Duration? = null, fieldExpire: Duration? = null, getData: suspend MongoCollection<T>.() -> T?): T?
Link copied to clipboard
suspend fun <T : Model> getAll(collection: MongoCollection<T>, serializer: KSerializer<T>, expire: Duration? = null, cacheKey: String = collection.cacheKey(), maxCacheSize: Int? = null, getData: suspend MongoCollection<T>.() -> List<T>): List<T>
Link copied to clipboard
suspend fun <T : Model, R : Any> getVolatile(fieldName: String, collection: MongoCollection<T>, serializer: KSerializer<R>, setData: suspend MongoCollection<T>.() -> R): R
Link copied to clipboard
suspend fun <T : Model> remove(id: String, collection: MongoCollection<T>, deleteData: suspend MongoCollection<T>.() -> Boolean): Boolean
Link copied to clipboard
suspend fun <T : Model> removeAll(collection: MongoCollection<T>, cacheKey: String = collection.cacheKey(), deleteData: suspend MongoCollection<T>.() -> Boolean): Boolean
Link copied to clipboard
suspend fun <T : Model> set(collection: MongoCollection<T>, cacheKey: String = collection.cacheKey(), serializer: KSerializer<T>, expire: Duration? = null, fieldExpire: Duration? = null, invalidateVolatiles: Boolean = true, setData: suspend MongoCollection<T>.() -> T?): T?
Link copied to clipboard
suspend fun <T : Model> setAll(collection: MongoCollection<T>, serializer: KSerializer<T>, expire: Duration? = null, fieldExpire: Duration? = null, invalidateVolatiles: Boolean = true, maxCacheSize: Int? = null, cacheKey: String = collection.cacheKey(), setData: suspend MongoCollection<T>.() -> List<T>?): Boolean
Link copied to clipboard
suspend fun <T : Model> setAllAsync(items: List<T>, collection: MongoCollection<T>, serializer: KSerializer<T>, expire: Duration? = null, fieldExpire: Duration? = null, writeData: suspend MongoCollection<T>.(List<T>) -> Unit)
Link copied to clipboard
suspend fun <T : Model> setAsync(item: T, collection: MongoCollection<T>, serializer: KSerializer<T>, expire: Duration? = null, fieldExpire: Duration? = null, writeData: suspend MongoCollection<T>.(T) -> Unit)