
Manages object pooling efficiently, enhancing resource reuse and performance in applications. Supports LIFO strategy, customizable configurations, and adapts to various environments with ease.
KOP is a Kotlin Multiplatform object pool.
dependencies {
// ...
implementation("io.github.domgew:kop:<current_version>")
// OR just for JVM:
implementation("io.github.domgew:kop-jvm:<current_version>")
// ...
}repositories {
mavenCentral()
// ...
}See Dokka-generated docs.
typealias ObjectType = Any
suspend fun createObjectInstance(): ObjectType =
TODO()
val objectPool = KotlinObjectPool(
config = KotlinObjectPoolConfig(
maxSize = 4,
keepAliveFor = 1.minutes,
strategy = KotlinObjectPoolStrategy.LIFO,
),
// ...
) {
createObjectInstance()
}
// OR
val objectPool = KotlinObjectPool.build {
maxSize(4)
keepAliveFor(1.minutes)
strategy(KotlinObjectPoolStrategy.LIFO)
// ...
createInstance {
createObjectInstance()
}
}
suspend fun callObject() =
objectPool.withObject { instance ->
instance.call()
}Supported Targets:
val kedisConfiguration: KedisConfiguration = TODO()
suspend fun KedisClient.getFromCache(): String =
TODO()
val objectPool = KotlinObjectPool(
KotlinObjectPoolConfig(
maxSize = 4,
keepAliveFor = 1.minutes,
strategy = KotlinObjectPoolStrategy.LIFO,
),
) {
KedisClient(kedisConfiguration)
}
suspend fun getValueWithCache() =
objectPool.withObject { kedisClient: KedisClient ->
kedisClient.getFromCache()
}KOP is a Kotlin Multiplatform object pool.
dependencies {
// ...
implementation("io.github.domgew:kop:<current_version>")
// OR just for JVM:
implementation("io.github.domgew:kop-jvm:<current_version>")
// ...
}repositories {
mavenCentral()
// ...
}See Dokka-generated docs.
typealias ObjectType = Any
suspend fun createObjectInstance(): ObjectType =
TODO()
val objectPool = KotlinObjectPool(
config = KotlinObjectPoolConfig(
maxSize = 4,
keepAliveFor = 1.minutes,
strategy = KotlinObjectPoolStrategy.LIFO,
),
// ...
) {
createObjectInstance()
}
// OR
val objectPool = KotlinObjectPool.build {
maxSize(4)
keepAliveFor(1.minutes)
strategy(KotlinObjectPoolStrategy.LIFO)
// ...
createInstance {
createObjectInstance()
}
}
suspend fun callObject() =
objectPool.withObject { instance ->
instance.call()
}Supported Targets:
val kedisConfiguration: KedisConfiguration = TODO()
suspend fun KedisClient.getFromCache(): String =
TODO()
val objectPool = KotlinObjectPool(
KotlinObjectPoolConfig(
maxSize = 4,
keepAliveFor = 1.minutes,
strategy = KotlinObjectPoolStrategy.LIFO,
),
) {
KedisClient(kedisConfiguration)
}
suspend fun getValueWithCache() =
objectPool.withObject { kedisClient: KedisClient ->
kedisClient.getFromCache()
}