Skip to content

Latest commit

 

History

History
executable file
·
34 lines (31 loc) · 862 Bytes

File metadata and controls

executable file
·
34 lines (31 loc) · 862 Bytes

Ktor Simple Memory Cache

Memory cache provider for Ktor Simple Cache plugin

Maven Central with version prefix filter

Setup

Gradle

repositories {
    mavenCentral()
}

implementation("com.ucasoft.ktor:ktor-simple-memory-cache:0.51.2")

Usage

    install(SimpleCache) {
        memoryCache {
            invalidateAt = 10.seconds
        }
    }

    routing {
        cacheOutput(2.seconds) {
            get("short-cache") {
                call.respond(Random.nextInt())
            }
        }
        cacheOutput {
            get("default-cache") {
                call.respond(Random.nextInt())
            }
        }
    }