Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encode with null value == remove key ??? #1323

Closed
jqctop1 opened this issue Jun 6, 2024 · 2 comments
Closed

encode with null value == remove key ??? #1323

jqctop1 opened this issue Jun 6, 2024 · 2 comments

Comments

@jqctop1
Copy link

jqctop1 commented Jun 6, 2024

Note:

An crash issue will be ignored & closed in a week without logs.

The language of MMKV

Kotlin

The version of MMKV

1.3.4
Note: For versions older than the latest version, please upgrade before posting any issue.
We don't have much time for old version tech support.

The platform of MMKV

Android

What is the issue?

mmkv.encodeString(key, null)
mmkv.containsKey(key) 会返回false
这个api设计的合理吗?有多少人知道encode一个null就等价于删掉key?

还有removeKey的默认实现就是removeValueForKey 。。。这样暴露两个接口的目的是什么?

@lingol
Copy link
Collaborator

lingol commented Jun 6, 2024

It's a common practice whenever a null value is stored the key gets deleted.

@lingol
Copy link
Collaborator

lingol commented Jun 6, 2024

As for the duplication of remove() & removeValueForKey(), MMKV originally provides removeValueForKey().
Later on, to make the migration from SharedPreferences to MMKV easy, MMKV implements the interface SharedPreferences.Editor which provides remove().

Now it is too late to remove either one of them.
Sorry for any trouble or misunderstanding.

@lingol lingol closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants