| 161 | } |
| 162 | |
| 163 | MMKV_EXPORT void *getDefaultMMKV(int32_t mode, const char *cryptKey, bool aes256, size_t expectedCapacity, |
| 164 | int32_t enableKeyExpire, int32_t expiredInSeconds, bool enableCompareBeforeSet, |
| 165 | int32_t recover, uint32_t itemSizeLimit) { |
| 166 | MMKV *kv = nullptr; |
| 167 | |
| 168 | auto config = MMKVConfig(); |
| 169 | config.mode = (MMKVMode) mode; |
| 170 | config.aes256 = aes256; |
| 171 | config.expectedCapacity = expectedCapacity; |
| 172 | if (enableKeyExpire >= 0) { |
| 173 | config.enableKeyExpire = (enableKeyExpire != 0); |
| 174 | } |
| 175 | config.expiredInSeconds = expiredInSeconds; |
| 176 | config.enableCompareBeforeSet = enableCompareBeforeSet; |
| 177 | if (recover >= 0) { |
| 178 | config.recover = static_cast<MMKVRecoverStrategic>(recover); |
| 179 | } |
| 180 | config.itemSizeLimit = itemSizeLimit; |
| 181 | |
| 182 | if (cryptKey) { |
| 183 | string crypt = cryptKey; |
| 184 | if (crypt.length() > 0) { |
| 185 | config.cryptKey = &crypt; |
| 186 | kv = MMKV::defaultMMKV(config); |
| 187 | } |
| 188 | } |
| 189 | if (!kv) { |
| 190 | kv = MMKV::defaultMMKV(config); |
| 191 | } |
| 192 | |
| 193 | return kv; |
| 194 | } |
| 195 | |
| 196 | MMKV_EXPORT const char *mmapID(void *handle) { |
| 197 | MMKV *kv = static_cast<MMKV *>(handle); |