appleMain.com.configcat.Cache.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of configcat-kotlin-client Show documentation
Show all versions of configcat-kotlin-client Show documentation
Kotlin Multiplatform SDK for ConfigCat, a feature flag, feature toggle, and configuration management service. That lets you launch new features and change your software configuration remotely without actually (re)deploying code. ConfigCat even helps you do controlled roll-outs like canary releases and blue-green deployments.
package com.configcat
import platform.Foundation.NSUserDefaults
internal actual fun defaultCache(): ConfigCache {
return UserDefaultsCache()
}
/**
* [ConfigCache] implementation that uses [NSUserDefaults] as persistent storage.
*/
public class UserDefaultsCache : ConfigCache {
private val userDefaults = NSUserDefaults.standardUserDefaults
private val prefix = "com.configcat"
override suspend fun read(key: String): String? = userDefaults.stringForKey("$prefix-$key")
override suspend fun write(
key: String,
value: String,
) {
userDefaults.setObject(value, "$prefix-$key")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy