KacheController
class KacheController(val cacheEnabled: () -> Boolean = { true }, client: RedisCoroutinesCommands<String, String>)
Properties
Functions
Link copied to clipboard
suspend fun <T : Model> getAll(collection: MongoCollection<T>, serializer: KSerializer<T>, cacheKey: String = collection.cacheKey(), getData: suspend MongoCollection<T>.() -> List<T>): List<T>
Get the items from the list if they exist else perform the real query update the cache and return the results
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
Volatiles are queries whose result depends on the state of the collection i.e if an items is added, modified or deleted it'll affect the response of the query e.g
Link copied to clipboard
Link copied to clipboard
suspend fun <T : Model> setAll(collection: MongoCollection<T>, serializer: KSerializer<T>, cacheKey: String = collection.cacheKey(), setData: suspend MongoCollection<T>.() -> List<T>?): Boolean
Insert or update multiple items in your db and return the updated items. This will update their data in the cache buy their id
Link copied to clipboard