dev.mokkery.plugin.core.Cache.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mokkery-plugin Show documentation
Show all versions of mokkery-plugin Show documentation
Mokkery is a mocking library for Kotlin Multiplatform, easy to use, boilerplate-free and compiler plugin driven.
The newest version!
package dev.mokkery.plugin.core
interface Cache {
fun getOrPut(key: K, block: () -> V): V
fun clear()
}
fun Cache(): Cache = HashMapCache()
private class HashMapCache : Cache {
private val map = mutableMapOf()
override fun getOrPut(key: K, block: () -> V): V = map.getOrPut(key, block)
override fun clear() = map.clear()
}