Skip to content

Commit

Permalink
add filterExpire param for count() & allKeys() for flutter iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
lingol committed Aug 10, 2023
1 parent cffee73 commit c4b9ccc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions flutter/ios/Classes/flutter-bridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ MMKV_EXPORT int32_t MMKV_FUNC(writeValueToNB)(const void *handle, char *oKey, vo
return -1;
}

MMKV_EXPORT uint64_t MMKV_FUNC(allKeys)(const void *handle, char ***keyArrayPtr, uint32_t **sizeArrayPtr) {
MMKV_EXPORT uint64_t MMKV_FUNC(allKeys)(const void *handle, char ***keyArrayPtr, uint32_t **sizeArrayPtr, bool filterExpire) {
MMKV *kv = (__bridge MMKV *) handle;
if (kv) {
auto keys = [kv allKeys];
auto keys = filterExpire ? [kv allNonExpiredKeys] : [kv allKeys];
if (keys.count > 0) {
auto keyArray = (char **) malloc(keys.count * sizeof(void *));
auto sizeArray = (uint32_t *) malloc(keys.count * sizeof(uint32_t *));
Expand Down Expand Up @@ -336,10 +336,10 @@ MMKV_EXPORT bool MMKV_FUNC(containsKey)(const void *handle, char *oKey) {
return false;
}

MMKV_EXPORT uint64_t MMKV_FUNC(count)(const void *handle) {
MMKV_EXPORT uint64_t MMKV_FUNC(count)(const void *handle, bool filterExpire) {
MMKV *kv = (__bridge MMKV *) handle;
if (kv) {
return [kv count];
return filterExpire ? [kv countNonExpiredKeys] : [kv count];
}
return 0;
}
Expand Down

0 comments on commit c4b9ccc

Please sign in to comment.