configcat / kotlin-sdk

ConfigCat SDK for Kotlin Multiplatform. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
https://configcat.com/docs/sdk-reference/kotlin
MIT License
14 stars 0 forks source link

ConfigCache nullable values? #1

Closed valeriyo closed 1 year ago

valeriyo commented 2 years ago

I migrated from configcat-android-client and it was quite strange that interface ConfigCache uses empty strings instead of null to indicate "no value". Please change it:

This would be a breaking change, but I think it's worth getting it right.

z4kn4fein commented 2 years ago

Hi @valeriyo, thank you for reporting! I'm planning to apply our ongoing SDK improvements (e.g., for swift here) to this SDK next. It'll include the success indication of forceRefresh() that you reported on the Android SDK, and I'll also include the fix for this issue.

About the issue: I'm not sure why the write() should take String?; the SDK won't call write() if it does not have a valid value to save. What do you think?

z4kn4fein commented 1 year ago

Hi @valeriyo, we released a new version of the Kotlin SDK (v1.0.2) with fixes to the related issues. Feel free to let us know if you have more suggestions.

valeriyo commented 1 year ago

@z4kn4fein the ConfigCache.read returns String? (which is correct) but the write(key: String, value: String) doesn't allow null value, is that intentional? I think it's a mistake - empty string should be a valid value, and there should be a way to clear out the cached value with a null. Thanks!

z4kn4fein commented 1 year ago

Hi @valeriyo, the SDK won't call write() when it doesn't have a valid value to cache. There's no such case as the SDK clearing the cache, it only writes the latest valid (non-empty and non-null) configuration into it.

valeriyo commented 1 year ago

Oh ok - so once a value is written, it will stay there forever (as long as the app is installed).. I guess that's expected?

z4kn4fein commented 1 year ago

Yep, it'll stay there and will be reused. The SDK determines the cache key from the SDK keys you use, so it'll use a single cache entry per SDK key. It'll overwrite the same entry when a config for an SDK key is updated.

github-actions[bot] commented 1 year ago

This issue is marked stale because it has no activity in the last 3 weeks. The issue will be closed in one week. Please remove the stale flag to keep it open.

github-actions[bot] commented 1 year ago

This issue was closed due to no activity.