react-native-mmkv 3.0.0-beta.2 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MMKV/Core/CMakeLists.txt +12 -4
- package/MMKV/Core/Core.xcodeproj/project.pbxproj +13 -4
- package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme +1 -1
- package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/MMKVWatchCore.xcscheme +1 -1
- package/MMKV/Core/MMKV.cpp +3 -4
- package/MMKV/Core/MMKVLog_Android.cpp +56 -1
- package/MMKV/Core/MMKVPredef.h +8 -1
- package/MMKV/Core/MMKV_Android.cpp +3 -3
- package/MMKV/Core/MMKV_IO.cpp +1 -1
- package/MMKV/Core/MemoryFile.cpp +33 -2
- package/MMKV/Core/MemoryFile.h +1 -0
- package/MMKV/Core/MemoryFile_Android.cpp +13 -3
- package/MMKV/Core/MemoryFile_Linux.cpp +8 -3
- package/MMKV/Core/MemoryFile_Win32.cpp +3 -3
- package/MMKV/Core/ThreadLock.cpp +9 -5
- package/MMKV/Core/ThreadLock.h +2 -3
- package/MMKV/Core/aes/AESCrypt.h +1 -0
- package/MMKV/Core/aes/openssl/openssl_aes.h +12 -0
- package/MMKV/Core/aes/openssl/openssl_aes_core.cpp +4 -4
- package/MMKV/Core/core.vcxproj +102 -0
- package/MMKV/Core/crc32/Checksum.h +5 -0
- package/MMKV/Core/crc32/crc32_armv8.cpp +3 -1
- package/MMKV/Core/crc32/zlib/CMakeLists.txt +60 -0
- package/MMKV/LICENSE.TXT +193 -0
- package/MMKV/README.md +74 -10
- package/README.md +12 -5
- package/cpp/MmkvHostObject.cpp +1 -0
- package/cpp/NativeMmkvModule.cpp +2 -5
- package/lib/commonjs/LazyTurboModule.js +26 -9
- package/lib/commonjs/LazyTurboModule.js.map +1 -1
- package/lib/commonjs/MMKV.js +1 -1
- package/lib/commonjs/MMKV.js.map +1 -1
- package/lib/commonjs/PlatformChecker.js +3 -3
- package/lib/commonjs/PlatformChecker.js.map +1 -1
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/LazyTurboModule.js +26 -9
- package/lib/module/LazyTurboModule.js.map +1 -1
- package/lib/module/MMKV.js +2 -2
- package/lib/module/MMKV.js.map +1 -1
- package/lib/module/PlatformChecker.js +2 -2
- package/lib/module/PlatformChecker.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/LazyTurboModule.d.ts +3 -0
- package/lib/typescript/src/LazyTurboModule.d.ts.map +1 -1
- package/lib/typescript/src/PlatformChecker.d.ts +1 -1
- package/lib/typescript/src/PlatformChecker.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/react-native.config.js +1 -1
- package/src/LazyTurboModule.ts +48 -12
- package/src/MMKV.ts +2 -2
- package/src/PlatformChecker.ts +4 -2
- package/src/index.ts +2 -0
package/MMKV/Core/core.vcxproj
CHANGED
|
@@ -5,10 +5,18 @@
|
|
|
5
5
|
<Configuration>Debug</Configuration>
|
|
6
6
|
<Platform>Win32</Platform>
|
|
7
7
|
</ProjectConfiguration>
|
|
8
|
+
<ProjectConfiguration Include="Debug|x64">
|
|
9
|
+
<Configuration>Debug</Configuration>
|
|
10
|
+
<Platform>x64</Platform>
|
|
11
|
+
</ProjectConfiguration>
|
|
8
12
|
<ProjectConfiguration Include="Release|Win32">
|
|
9
13
|
<Configuration>Release</Configuration>
|
|
10
14
|
<Platform>Win32</Platform>
|
|
11
15
|
</ProjectConfiguration>
|
|
16
|
+
<ProjectConfiguration Include="Release|x64">
|
|
17
|
+
<Configuration>Release</Configuration>
|
|
18
|
+
<Platform>x64</Platform>
|
|
19
|
+
</ProjectConfiguration>
|
|
12
20
|
</ItemGroup>
|
|
13
21
|
<ItemGroup>
|
|
14
22
|
<ClCompile Include="aes\AESCrypt.cpp" />
|
|
@@ -77,11 +85,21 @@
|
|
|
77
85
|
<CharacterSet>Unicode</CharacterSet>
|
|
78
86
|
<PlatformToolset>v143</PlatformToolset>
|
|
79
87
|
</PropertyGroup>
|
|
88
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
89
|
+
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
90
|
+
<CharacterSet>Unicode</CharacterSet>
|
|
91
|
+
<PlatformToolset>v143</PlatformToolset>
|
|
92
|
+
</PropertyGroup>
|
|
80
93
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
81
94
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
82
95
|
<CharacterSet>Unicode</CharacterSet>
|
|
83
96
|
<PlatformToolset>v143</PlatformToolset>
|
|
84
97
|
</PropertyGroup>
|
|
98
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
99
|
+
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
100
|
+
<CharacterSet>Unicode</CharacterSet>
|
|
101
|
+
<PlatformToolset>v143</PlatformToolset>
|
|
102
|
+
</PropertyGroup>
|
|
85
103
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
86
104
|
<ImportGroup Label="ExtensionSettings">
|
|
87
105
|
</ImportGroup>
|
|
@@ -94,11 +112,15 @@
|
|
|
94
112
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
|
95
113
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
|
96
114
|
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">mmkv</TargetName>
|
|
115
|
+
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">mmkv</TargetName>
|
|
97
116
|
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.lib</TargetExt>
|
|
117
|
+
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.lib</TargetExt>
|
|
98
118
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
|
99
119
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
|
100
120
|
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">mmkv</TargetName>
|
|
121
|
+
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">mmkv</TargetName>
|
|
101
122
|
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.lib</TargetExt>
|
|
123
|
+
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.lib</TargetExt>
|
|
102
124
|
</PropertyGroup>
|
|
103
125
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
104
126
|
<ClCompile>
|
|
@@ -140,6 +162,46 @@
|
|
|
140
162
|
<Message>Copying Headers</Message>
|
|
141
163
|
</PostBuildEvent>
|
|
142
164
|
</ItemDefinitionGroup>
|
|
165
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
166
|
+
<ClCompile>
|
|
167
|
+
<AdditionalIncludeDirectories>Z:\mmkv\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
168
|
+
<AdditionalOptions>%(AdditionalOptions) -std:c++latest</AdditionalOptions>
|
|
169
|
+
<AssemblerListingLocation>Debug/</AssemblerListingLocation>
|
|
170
|
+
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
171
|
+
<CompileAs>CompileAsCpp</CompileAs>
|
|
172
|
+
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
173
|
+
<ExceptionHandling>Sync</ExceptionHandling>
|
|
174
|
+
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
|
175
|
+
<Optimization>Disabled</Optimization>
|
|
176
|
+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
177
|
+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
178
|
+
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
179
|
+
<WarningLevel>Level3</WarningLevel>
|
|
180
|
+
<PreprocessorDefinitions>_WINDOWS;_CRT_SECURE_NO_WARNINGS;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
181
|
+
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
182
|
+
</ClCompile>
|
|
183
|
+
<ResourceCompile>
|
|
184
|
+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
185
|
+
<AdditionalIncludeDirectories>Z:\mmkv\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
186
|
+
</ResourceCompile>
|
|
187
|
+
<Midl>
|
|
188
|
+
<AdditionalIncludeDirectories>Z:\mmkv\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
189
|
+
<OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
|
|
190
|
+
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
191
|
+
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
192
|
+
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
193
|
+
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
194
|
+
</Midl>
|
|
195
|
+
<Lib>
|
|
196
|
+
<AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
|
|
197
|
+
</Lib>
|
|
198
|
+
<PostBuildEvent>
|
|
199
|
+
<Command>for %%f in ("$(ProjectDir)MMKV.h", "$(ProjectDir)MMBuffer.h", "$(ProjectDir)MMKVPredef.h") do xcopy /y /i %%f "$(OutDir)\include\MMKV\"</Command>
|
|
200
|
+
</PostBuildEvent>
|
|
201
|
+
<PostBuildEvent>
|
|
202
|
+
<Message>Copying Headers</Message>
|
|
203
|
+
</PostBuildEvent>
|
|
204
|
+
</ItemDefinitionGroup>
|
|
143
205
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
144
206
|
<ClCompile>
|
|
145
207
|
<AdditionalIncludeDirectories>Z:\mmkv\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
@@ -180,6 +242,46 @@
|
|
|
180
242
|
<Message>Copying Headers</Message>
|
|
181
243
|
</PostBuildEvent>
|
|
182
244
|
</ItemDefinitionGroup>
|
|
245
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
246
|
+
<ClCompile>
|
|
247
|
+
<AdditionalIncludeDirectories>Z:\mmkv\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
248
|
+
<AdditionalOptions>%(AdditionalOptions) -std:c++latest</AdditionalOptions>
|
|
249
|
+
<AssemblerListingLocation>Release/</AssemblerListingLocation>
|
|
250
|
+
<CompileAs>CompileAsCpp</CompileAs>
|
|
251
|
+
<ExceptionHandling>Sync</ExceptionHandling>
|
|
252
|
+
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
253
|
+
<Optimization>MaxSpeed</Optimization>
|
|
254
|
+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
255
|
+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
256
|
+
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
257
|
+
<WarningLevel>Level3</WarningLevel>
|
|
258
|
+
<PreprocessorDefinitions>WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
259
|
+
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
260
|
+
<DebugInformationFormat>
|
|
261
|
+
</DebugInformationFormat>
|
|
262
|
+
</ClCompile>
|
|
263
|
+
<ResourceCompile>
|
|
264
|
+
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
265
|
+
<AdditionalIncludeDirectories>Z:\mmkv\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
266
|
+
</ResourceCompile>
|
|
267
|
+
<Midl>
|
|
268
|
+
<AdditionalIncludeDirectories>Z:\mmkv\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
269
|
+
<OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
|
|
270
|
+
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
271
|
+
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
272
|
+
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
273
|
+
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
274
|
+
</Midl>
|
|
275
|
+
<Lib>
|
|
276
|
+
<AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
|
|
277
|
+
</Lib>
|
|
278
|
+
<PostBuildEvent>
|
|
279
|
+
<Command>for %%f in ("$(ProjectDir)MMKV.h", "$(ProjectDir)MMBuffer.h", "$(ProjectDir)MMKVPredef.h") do xcopy /y /i %%f "$(OutDir)\include\MMKV\"</Command>
|
|
280
|
+
</PostBuildEvent>
|
|
281
|
+
<PostBuildEvent>
|
|
282
|
+
<Message>Copying Headers</Message>
|
|
283
|
+
</PostBuildEvent>
|
|
284
|
+
</ItemDefinitionGroup>
|
|
183
285
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
184
286
|
<ImportGroup Label="ExtensionTargets">
|
|
185
287
|
</ImportGroup>
|
|
@@ -53,9 +53,14 @@ namespace mmkv {
|
|
|
53
53
|
uint32_t armv8_crc32(uint32_t crc, const uint8_t *buf, size_t len);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
# ifdef MMKV_OHOS
|
|
57
|
+
// getauxval(AT_HWCAP) in OHOS returns wrong value, we just assume all OHOS device have crc32 instr
|
|
58
|
+
# define CRC32 mmkv::armv8_crc32
|
|
59
|
+
# else
|
|
56
60
|
// have to check CPU's instruction set dynamically
|
|
57
61
|
typedef uint32_t (*CRC32_Func_t)(uint32_t crc, const uint8_t *buf, size_t len);
|
|
58
62
|
extern CRC32_Func_t CRC32;
|
|
63
|
+
# endif
|
|
59
64
|
|
|
60
65
|
#else // defined(__aarch64__) && defined(__linux__)
|
|
61
66
|
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
|
|
23
23
|
#ifdef MMKV_USE_ARMV8_CRC32
|
|
24
24
|
|
|
25
|
-
#
|
|
25
|
+
# ifdef CRC32
|
|
26
|
+
// nothing to do
|
|
27
|
+
# elif MMKV_EMBED_ZLIB
|
|
26
28
|
|
|
27
29
|
static inline uint32_t _crc32Wrap(uint32_t crc, const uint8_t *buf, size_t len) {
|
|
28
30
|
return static_cast<uint32_t>(zlib::crc32(crc, buf, static_cast<uInt>(len)));
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Tencent is pleased to support the open source community by making
|
|
3
|
+
# MMKV available.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2020 THL A29 Limited, a Tencent company.
|
|
6
|
+
# All rights reserved.
|
|
7
|
+
#
|
|
8
|
+
# Licensed under the BSD 3-Clause License (the "License"); you may not use
|
|
9
|
+
# this file except in compliance with the License. You may obtain a copy of
|
|
10
|
+
# the License at
|
|
11
|
+
#
|
|
12
|
+
# https://opensource.org/licenses/BSD-3-Clause
|
|
13
|
+
#
|
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
# See the License for the specific language governing permissions and
|
|
18
|
+
# limitations under the License.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
# Sets the minimum version of CMake required to build the native library.
|
|
22
|
+
|
|
23
|
+
cmake_minimum_required(VERSION 3.10.0)
|
|
24
|
+
|
|
25
|
+
project(z)
|
|
26
|
+
|
|
27
|
+
IF(APPLE)
|
|
28
|
+
add_compile_definitions(FORCE_POSIX)
|
|
29
|
+
ENDIF()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# Creates and names a library, sets it as either STATIC
|
|
33
|
+
# or SHARED, and provides the relative paths to its source code.
|
|
34
|
+
# You can define multiple libraries, and CMake builds them for you.
|
|
35
|
+
# Gradle automatically packages shared libraries with your APK.
|
|
36
|
+
|
|
37
|
+
add_library( # Sets the name of the library.
|
|
38
|
+
z
|
|
39
|
+
|
|
40
|
+
# Sets the library as a shared library.
|
|
41
|
+
STATIC
|
|
42
|
+
|
|
43
|
+
# Provides a relative path to your source file(s).
|
|
44
|
+
crc32.h
|
|
45
|
+
crc32.cpp
|
|
46
|
+
zconf.h
|
|
47
|
+
zutil.h
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
set_target_properties(z PROPERTIES
|
|
52
|
+
CXX_STANDARD 17
|
|
53
|
+
CXX_EXTENSIONS OFF
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# Specifies libraries CMake should link to your target library. You
|
|
57
|
+
# can link multiple libraries, such as libraries you define in this
|
|
58
|
+
# build script, prebuilt third-party libraries, or system libraries.
|
|
59
|
+
|
|
60
|
+
|
package/MMKV/LICENSE.TXT
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Tencent is pleased to support the open source community by making MMKV available.
|
|
2
|
+
Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
If you have downloaded a copy of the MMKV binary from Tencent, please note that the MMKV binary is licensed under the BSD 3-Clause License.
|
|
4
|
+
If you have downloaded a copy of the MMKV source code from Tencent, please note that MMKV source code is licensed under the BSD 3-Clause License, except for the third-party components listed below which are subject to different license terms. Your integration of MMKV into your own projects may require compliance with the BSD 3-Clause License, as well as the other licenses applicable to the third-party components included within MMKV.
|
|
5
|
+
A copy of the BSD 3-Clause License is included in this file.
|
|
6
|
+
|
|
7
|
+
Other dependencies and licenses:
|
|
8
|
+
|
|
9
|
+
Open Source Software Licensed Under the OpenSSL License:
|
|
10
|
+
----------------------------------------------------------------------------------------
|
|
11
|
+
1. OpenSSL 1.1.0i
|
|
12
|
+
Copyright (c) 1998-2018 The OpenSSL Project.
|
|
13
|
+
All rights reserved.
|
|
14
|
+
Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
|
15
|
+
All rights reserved.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Terms of the OpenSSL License:
|
|
19
|
+
---------------------------------------------------
|
|
20
|
+
LICENSE ISSUES:
|
|
21
|
+
--------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the OpenSSL License and the original SSLeay license apply to the toolkit.
|
|
24
|
+
See below for the actual license texts.
|
|
25
|
+
|
|
26
|
+
OpenSSL License:
|
|
27
|
+
--------------------------------------------------------------------
|
|
28
|
+
Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
|
|
29
|
+
|
|
30
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
31
|
+
|
|
32
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
33
|
+
|
|
34
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
35
|
+
|
|
36
|
+
3. All advertising materials mentioning features or use of this software must display the following acknowledgment:
|
|
37
|
+
"This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
|
38
|
+
|
|
39
|
+
4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact openssl-core@openssl.org.
|
|
40
|
+
|
|
41
|
+
5. Products derived from this software may not be called "OpenSSL" nor may "OpenSSL" appear in their names without prior written permission of the OpenSSL Project.
|
|
42
|
+
|
|
43
|
+
6. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
|
44
|
+
|
|
45
|
+
THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
46
|
+
====================================================================
|
|
47
|
+
* This product includes cryptographic software written by Eric Young (eay@cryptsoft.com). This product includes software written by Tim Hudson (tjh@cryptsoft.com).
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Original SSLeay License:
|
|
51
|
+
--------------------------------------------------------------------
|
|
52
|
+
Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
|
53
|
+
All rights reserved.
|
|
54
|
+
|
|
55
|
+
This package is an SSL implementation written by Eric Young (eay@cryptsoft.com).
|
|
56
|
+
The implementation was written so as to conform with Netscapes SSL.
|
|
57
|
+
|
|
58
|
+
This library is free for commercial and non-commercial use as long as the following conditions are aheared to. The following conditions apply to all code found in this distribution, be it the RC4, RSA, lhash, DES, etc., code; not just the SSL code. The SSL documentation included with this distribution is covered by the same copyright terms except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
|
59
|
+
|
|
60
|
+
Copyright remains Eric Young's, and as such any Copyright notices in the code are not to be removed. If this package is used in a product, Eric Young should be given attribution as the author of the parts of the library used. This can be in the form of a textual message at program startup or in documentation (online or textual) provided with the package.
|
|
61
|
+
|
|
62
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
63
|
+
1. Redistributions of source code must retain the copyright notice, this list of conditions and the following disclaimer.
|
|
64
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
65
|
+
3. All advertising materials mentioning features or use of this software must display the following acknowledgement:" This product includes cryptographic software written by Eric Young (eay@cryptsoft.com)" The word 'cryptographic' can be left out if the rouines from the library being used are not cryptographic related :-).
|
|
66
|
+
4. If you include any Windows specific code (or a derivative thereof) from the apps directory (application code) you must include an acknowledgement: "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
|
67
|
+
|
|
68
|
+
THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
69
|
+
|
|
70
|
+
The licence and distribution terms for any publically available version or derivative of this code cannot be changed. i.e. this code cannot simply be copied and put under another distribution licence [including the GNU Public Licence.]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
Open Source Software Licensed Under the Apache License, Version 2.0:
|
|
75
|
+
The below software in this distribution may have been modified by THL A29 Limited (“Tencent Modifications”). All Tencent Modifications are Copyright (C) 2018 THL A29 Limited.
|
|
76
|
+
----------------------------------------------------------------------------------------
|
|
77
|
+
1. MultiprocessSharedPreferences v1.0
|
|
78
|
+
Copyright (C) 2014 seven456@gmail.com
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
Terms of the Apache License, Version 2.0:
|
|
82
|
+
--------------------------------------------------------------------
|
|
83
|
+
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
|
|
84
|
+
|
|
85
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
86
|
+
|
|
87
|
+
1. Definitions.
|
|
88
|
+
|
|
89
|
+
“License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
90
|
+
|
|
91
|
+
“Licensor” shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
92
|
+
|
|
93
|
+
“Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
94
|
+
|
|
95
|
+
“You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
96
|
+
|
|
97
|
+
“Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
98
|
+
|
|
99
|
+
“Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
100
|
+
|
|
101
|
+
“Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
102
|
+
|
|
103
|
+
“Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
104
|
+
|
|
105
|
+
“Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as “Not a Contribution.”
|
|
106
|
+
|
|
107
|
+
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
108
|
+
|
|
109
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
110
|
+
|
|
111
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
112
|
+
|
|
113
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
114
|
+
|
|
115
|
+
a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
116
|
+
|
|
117
|
+
b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
118
|
+
|
|
119
|
+
c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
120
|
+
|
|
121
|
+
d) If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
124
|
+
|
|
125
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
126
|
+
|
|
127
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
128
|
+
|
|
129
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
130
|
+
|
|
131
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
132
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
133
|
+
|
|
134
|
+
END OF TERMS AND CONDITIONS
|
|
135
|
+
|
|
136
|
+
APPENDIX: How to apply the Apache License to your work
|
|
137
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
138
|
+
|
|
139
|
+
Copyright [yyyy] [name of copyright owner]
|
|
140
|
+
|
|
141
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
142
|
+
you may not use this file except in compliance with the License.
|
|
143
|
+
You may obtain a copy of the License at
|
|
144
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
145
|
+
Unless required by applicable law or agreed to in writing, software
|
|
146
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
148
|
+
See the License for the specific language governing permissions and
|
|
149
|
+
limitations under the License.
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
Open Source Software Licensed Under the zlib License:
|
|
154
|
+
The below software in this distribution may have been modified by THL A29 Limited (“Tencent Modifications”). All Tencent Modifications are Copyright (C) 2018 THL A29 Limited.
|
|
155
|
+
----------------------------------------------------------------------------------------
|
|
156
|
+
1. zlib v1.2.11
|
|
157
|
+
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
|
|
158
|
+
|
|
159
|
+
Terms of the zlib License:
|
|
160
|
+
--------------------------------------------------------------------
|
|
161
|
+
|
|
162
|
+
This software is provided 'as-is', without any express or implied
|
|
163
|
+
warranty. In no event will the authors be held liable for any damages
|
|
164
|
+
arising from the use of this software.
|
|
165
|
+
|
|
166
|
+
Permission is granted to anyone to use this software for any purpose,
|
|
167
|
+
including commercial applications, and to alter it and redistribute it
|
|
168
|
+
freely, subject to the following restrictions:
|
|
169
|
+
|
|
170
|
+
1. The origin of this software must not be misrepresented; you must not
|
|
171
|
+
claim that you wrote the original software. If you use this software
|
|
172
|
+
in a product, an acknowledgment in the product documentation would be
|
|
173
|
+
appreciated but is not required.
|
|
174
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
|
175
|
+
misrepresented as being the original software.
|
|
176
|
+
3. This notice may not be removed or altered from any source distribution.
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
Open Source Software Licensed Under the BSD 3-Clause License:
|
|
180
|
+
----------------------------------------------------------------------------------------
|
|
181
|
+
1. pybind11 v2.5.0
|
|
182
|
+
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.
|
|
183
|
+
|
|
184
|
+
Terms of the BSD 3-Clause License:
|
|
185
|
+
--------------------------------------------------------------------
|
|
186
|
+
|
|
187
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
188
|
+
|
|
189
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
190
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
191
|
+
Neither the name of [copyright holder] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
192
|
+
|
|
193
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/MMKV/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[](https://github.com/Tencent/MMKV/blob/master/LICENSE.TXT)
|
|
2
2
|
[](https://github.com/Tencent/MMKV/pulls)
|
|
3
|
-
[](https://github.com/Tencent/MMKV/releases)
|
|
4
|
+
[](https://github.com/Tencent/MMKV/wiki/home)
|
|
5
5
|
|
|
6
6
|
中文版本请参看[这里](./README_CN.md)
|
|
7
7
|
|
|
8
|
-
MMKV is an **efficient**, **small**, **easy-to-use** mobile key-value storage framework used in the WeChat application. It's currently available on **Android**, **iOS/macOS**, **
|
|
8
|
+
MMKV is an **efficient**, **small**, **easy-to-use** mobile key-value storage framework used in the WeChat application. It's currently available on **Android**, **iOS/macOS**, **Windows**, **POSIX** and **HarmonyOS NEXT**.
|
|
9
9
|
|
|
10
10
|
# MMKV for Android
|
|
11
11
|
|
|
@@ -28,8 +28,8 @@ Add the following lines to `build.gradle` on your app module:
|
|
|
28
28
|
|
|
29
29
|
```gradle
|
|
30
30
|
dependencies {
|
|
31
|
-
implementation 'com.tencent:mmkv:1.3.
|
|
32
|
-
// replace "1.3.
|
|
31
|
+
implementation 'com.tencent:mmkv:1.3.5'
|
|
32
|
+
// replace "1.3.5" with any available version
|
|
33
33
|
}
|
|
34
34
|
```
|
|
35
35
|
|
|
@@ -134,7 +134,7 @@ Writing random `int` for 10000 times, we get this chart:
|
|
|
134
134
|
For more benchmark data, please refer to [our benchmark](https://github.com/Tencent/MMKV/wiki/iOS_benchmark).
|
|
135
135
|
|
|
136
136
|
|
|
137
|
-
# MMKV for
|
|
137
|
+
# MMKV for Windows
|
|
138
138
|
|
|
139
139
|
## Features
|
|
140
140
|
|
|
@@ -170,7 +170,7 @@ note:
|
|
|
170
170
|
1. MMKV is compiled with `MT/MTd` runtime by default. If your project uses `MD/MDd`, you should change MMKV's setting to match your project's (`C/C++` -> `Code Generation` -> `Runtime Library`), or vice versa.
|
|
171
171
|
2. MMKV is developed with Visual Studio 2017, change the `Platform Toolset` if you use a different version of Visual Studio.
|
|
172
172
|
|
|
173
|
-
For other installation options, see [
|
|
173
|
+
For other installation options, see [Windows Setup](https://github.com/Tencent/MMKV/wiki/windows_setup).
|
|
174
174
|
|
|
175
175
|
### Quick Tutorial
|
|
176
176
|
You can use MMKV as you go. All changes are saved immediately, no `sync`, no `save` calls needed.
|
|
@@ -197,13 +197,13 @@ std::cout << "bool = " << mmkv->getBool("bool") << std::endl;
|
|
|
197
197
|
mmkv->set(1024, "int32");
|
|
198
198
|
std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;
|
|
199
199
|
|
|
200
|
-
mmkv->set("Hello, MMKV for
|
|
200
|
+
mmkv->set("Hello, MMKV for Windows", "string");
|
|
201
201
|
std::string result;
|
|
202
202
|
mmkv->getString("string", result);
|
|
203
203
|
std::cout << "string = " << result << std::endl;
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
MMKV also supports **Multi-Process Access**. Full tutorials can be found here [
|
|
206
|
+
MMKV also supports **Multi-Process Access**. Full tutorials can be found here [Windows Tutorial](https://github.com/Tencent/MMKV/wiki/windows_tutorial).
|
|
207
207
|
|
|
208
208
|
# MMKV for POSIX
|
|
209
209
|
|
|
@@ -263,13 +263,77 @@ std::cout << "bool = " << mmkv->getBool("bool") << std::endl;
|
|
|
263
263
|
mmkv->set(1024, "int32");
|
|
264
264
|
std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;
|
|
265
265
|
|
|
266
|
-
mmkv->set("Hello, MMKV for
|
|
266
|
+
mmkv->set("Hello, MMKV for Windows", "string");
|
|
267
267
|
std::string result;
|
|
268
268
|
mmkv->getString("string", result);
|
|
269
269
|
std::cout << "string = " << result << std::endl;
|
|
270
270
|
```
|
|
271
271
|
|
|
272
272
|
MMKV also supports **Multi-Process Access**. Full tutorials can be found here [POSIX Tutorial](https://github.com/Tencent/MMKV/wiki/posix_tutorial).
|
|
273
|
+
|
|
274
|
+
# MMKV for HarmonyOS NEXT
|
|
275
|
+
|
|
276
|
+
## Features
|
|
277
|
+
|
|
278
|
+
* **Efficient**. MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values, making the most of native platform to achieve best performance.
|
|
279
|
+
* **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.
|
|
280
|
+
|
|
281
|
+
* **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `sync`, no `flush` calls needed.
|
|
282
|
+
|
|
283
|
+
* **Small**.
|
|
284
|
+
* **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics and nothing more. It's really tidy.
|
|
285
|
+
* **About 600K in binary size**: MMKV adds about 600K per architecture on App size, and much less when zipped (HAR/HAP).
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
## Getting Started
|
|
289
|
+
### Installation via OHPM:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
ohpm install @tencent/mmkv
|
|
293
|
+
```
|
|
294
|
+
### Quick Tutorial
|
|
295
|
+
You can use MMKV as you go. All changes are saved immediately, no `sync`, no `apply` calls needed.
|
|
296
|
+
Setup MMKV on App startup, say your `EntryAbility.onCreate()` function, add these lines:
|
|
297
|
+
|
|
298
|
+
```js
|
|
299
|
+
import { MMKV } from '@tencent/mmkv';
|
|
300
|
+
|
|
301
|
+
export default class EntryAbility extends UIAbility {
|
|
302
|
+
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
|
303
|
+
let appCtx = this.context.getApplicationContext();
|
|
304
|
+
let mmkvRootDir = MMKV.initialize(appCtx);
|
|
305
|
+
console.info('mmkv rootDir: ', mmkvRootDir);
|
|
306
|
+
……
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
MMKV has a global instance, that can be used directly:
|
|
311
|
+
|
|
312
|
+
```js
|
|
313
|
+
import { MMKV } from '@tencent/mmkv';
|
|
314
|
+
|
|
315
|
+
let mmkv = MMKV.defaultMMKV();
|
|
316
|
+
mmkv.encodeBool('bool', true);
|
|
317
|
+
console.info('bool = ', mmkv.decodeBool('bool'));
|
|
318
|
+
|
|
319
|
+
mmkv.encodeInt32('int32', Math.pow(2, 31) - 1);
|
|
320
|
+
console.info('max int32 = ', mmkv.decodeInt32('int32'));
|
|
321
|
+
|
|
322
|
+
mmkv.encodeInt64('int', BigInt(2**63) - BigInt(1));
|
|
323
|
+
console.info('max int64 = ', mmkv.decodeInt64('int'));
|
|
324
|
+
|
|
325
|
+
let str: string = 'Hello OpenHarmony from MMKV';
|
|
326
|
+
mmkv.encodeString('string', str);
|
|
327
|
+
console.info('string = ', mmkv.decodeString('string'));
|
|
328
|
+
|
|
329
|
+
let arrayBuffer: ArrayBuffer = StringToArrayBuffer('Hello OpenHarmony from MMKV with bytes');
|
|
330
|
+
mmkv.encodeBytes('bytes', arrayBuffer);
|
|
331
|
+
let bytes = mmkv.decodeBytes('bytes');
|
|
332
|
+
console.info('bytes = ', ArrayBufferToString(bytes));
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
As you can see, MMKV is quite easy to use.
|
|
336
|
+
For the full documentation, see [HarmonyOS NEXT Tutorial](https://github.com/Tencent/MMKV/wiki/ohos_setup).
|
|
273
337
|
|
|
274
338
|
## License
|
|
275
339
|
MMKV is published under the BSD 3-Clause license. For details check out the [LICENSE.TXT](./LICENSE.TXT).
|
package/README.md
CHANGED
|
@@ -32,17 +32,24 @@
|
|
|
32
32
|
|
|
33
33
|
## Features
|
|
34
34
|
|
|
35
|
-
* **Get** and **set** strings, booleans and
|
|
35
|
+
* **Get** and **set** strings, booleans, numbers and ArrayBuffers
|
|
36
36
|
* **Fully synchronous** calls, no async/await, no Promises, no Bridge.
|
|
37
37
|
* **Encryption** support (secure storage)
|
|
38
38
|
* **Multiple instances** support (separate user-data with global data)
|
|
39
39
|
* **Customize storage location**
|
|
40
40
|
* **High performance** because everything is **written in C++**
|
|
41
41
|
* **~30x faster than AsyncStorage**
|
|
42
|
-
* Uses [**JSI**](https://github.com/react-native-
|
|
42
|
+
* Uses [**JSI**](https://reactnative.dev/docs/the-new-architecture/landing-page#fast-javascriptnative-interfacing) and [**C++ TurboModules**](https://github.com/reactwg/react-native-new-architecture/blob/main/docs/turbo-modules-xplat.md) instead of the "old" Bridge
|
|
43
43
|
* **iOS**, **Android** and **Web** support
|
|
44
44
|
* Easy to use **React Hooks** API
|
|
45
45
|
|
|
46
|
+
## react-native-mmkv V3
|
|
47
|
+
|
|
48
|
+
> [!IMPORTANT]
|
|
49
|
+
> react-native-mmkv V3 is now a pure C++ TurboModule, and **requires the new architecture to be enabled**.
|
|
50
|
+
> - If you want to use react-native-mmkv 3.x.x, you need to enable the new architecture in your app (see ["Enable the New Architecture for Apps"](https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md))
|
|
51
|
+
> - If you cannot use the new architecture yet, downgrade to react-native-mmkv 2.x.x for now.
|
|
52
|
+
|
|
46
53
|
## Sponsors
|
|
47
54
|
|
|
48
55
|
<div align="right">
|
|
@@ -108,7 +115,7 @@ See [Configuring App Groups](https://developer.apple.com/documentation/xcode/con
|
|
|
108
115
|
#### Customize
|
|
109
116
|
|
|
110
117
|
```js
|
|
111
|
-
import { MMKV } from 'react-native-mmkv'
|
|
118
|
+
import { MMKV, Mode } from 'react-native-mmkv'
|
|
112
119
|
|
|
113
120
|
export const storage = new MMKV({
|
|
114
121
|
id: `user-${userId}-storage`,
|
|
@@ -218,9 +225,9 @@ if (size >= 4096) {
|
|
|
218
225
|
}
|
|
219
226
|
```
|
|
220
227
|
|
|
221
|
-
## Testing with Jest
|
|
228
|
+
## Testing with Jest or Vitest
|
|
222
229
|
|
|
223
|
-
A mocked MMKV instance is automatically used when testing with Jest, so you will be able to use `new MMKV()` as per normal in your tests. Refer to [example/test/MMKV.test.ts](example/test/MMKV.test.ts) for an example.
|
|
230
|
+
A mocked MMKV instance is automatically used when testing with Jest or Vitest, so you will be able to use `new MMKV()` as per normal in your tests. Refer to [example/test/MMKV.test.ts](example/test/MMKV.test.ts) for an example using Jest.
|
|
224
231
|
|
|
225
232
|
## Documentation
|
|
226
233
|
|
package/cpp/MmkvHostObject.cpp
CHANGED
|
@@ -52,6 +52,7 @@ MmkvHostObject::~MmkvHostObject() {
|
|
|
52
52
|
if (instance != nullptr) {
|
|
53
53
|
std::string instanceId = instance->mmapID();
|
|
54
54
|
Logger::log("RNMMKV", "Destroying MMKV instance \"%s\"...", instanceId.c_str());
|
|
55
|
+
instance->sync();
|
|
55
56
|
instance->clearMemoryCache();
|
|
56
57
|
}
|
|
57
58
|
instance = nullptr;
|