All Downloads are FREE. Search and download functionalities are using the official Maven repository.

appleMain.com.configcat.Cache.kt Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 4.1.1
Show newest version
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