Kmemo
A Ktor server plugin that makes a SemanticCache available to every route handler.
kmemo is coroutine-native, so there is nothing to bridge — this plugin just installs your cache where handlers can reach it, and adds a getOrPut convenience so a handler caches an LLM call in one line, guards and all.
install(Kmemo) { cache = SemanticCache(embedder) }
routing {
post("/chat") {
val prompt = call.receiveText()
val answer = call.getOrPut(prompt) { llm.complete(it) }
call.respondText(answer)
}
}Content copied to clipboard