MMKV는 모바일 애플리케이션용으로 위챗에서 개발한 고성능이고 가벼운 키-값 저장 솔루션입니다. 안드로이드, iOS, macOS, Windows 및 리눅스 플랫폼에서 효율적인 데이터 지속성을 제공합니다. 속도와 신뢰성을 위해 설계된 MMKV는 메모리 매핑 파일을 사용하여 빠른 읽기/쓰기 작업을 제공하며, 사용자 설정, 세션 토큰 또는 캐시된 콘텐츠와 같은 소규모에서 중간 규모의 데이터를 저장하는 데 이상적입니다. 크로스플랫폼 지원은 다양한 기기 간 일관된 동작을 보장합니다. Flutter 플러그인은 최소한의 반복 코드로 통합을 단순화합니다.
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, with experimental Kotlin Multiplatform support.
MMKV for Kotlin Multiplatform
The v2.4.2 Kotlin Multiplatform package is experimental and currently targets
Android and iOS. Its API and artifact layout may change in a future release.
Add it to the shared module:
Supported targets are Android, iosArm64, iosSimulatorArm64, and iosX64. See the Kotlin Multiplatform guide for initialization and packaging details.
MMKV for Android
Features
Efficient. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of Android to achieve the best performance.
Multi-Process concurrency: MMKV supports concurrent read-read and read-write access between processes.
Easy-to-use. You can use MMKV as you go. All changes are saved immediately, no sync, no apply calls needed.
Small.
A handful of files: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.
About 50K in binary size: MMKV adds about 50K per architecture on App size, and much less when zipped (APK).
Getting Started
Installation Via Maven
Add the following lines to build.gradle on your app module:
dependencies {
implementation 'com.tencent:mmkv:2.4.2'
// replace "2.4.2" with any available version
}
Starting from v2.0.0, MMKV no longer supports 32-bit arch and API level 22 or 21, if you want 32-bit or API level 21~22, use v1.3.x LTS series.
You can use MMKV as you go. All changes are saved immediately, no sync, no apply calls needed.
Setup MMKV on App startup, say your Application class, add these lines:
MMKV also supports Multi-Process Access. Full tutorials can be found here Android Tutorial.
Performance
Writing random int for 1000 times, we get this chart:
For more benchmark data, please refer to our benchmark.
MMKV for iOS/macOS
Features
Efficient. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of iOS/macOS to achieve the best performance.
Easy-to-use. You can use MMKV as you go, no configurations are needed. All changes are saved immediately, no synchronize calls are needed.
Small.
A handful of files: MMKV contains encode/decode helpers and mmap logics and nothing more. It's really tidy.
Less than 30K in binary size: MMKV adds less than 30K per architecture on App size, and much less when zipped (IPA).
You can use MMKV as you go, no configurations are needed. All changes are saved immediately, no synchronize calls are needed.
Setup MMKV on App startup, in your -[MyApp application: didFinishLaunchingWithOptions:], add these lines:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// init MMKV in the main thread
[MMKV initializeMMKV:nil];
//...
return YES;
}
MMKV has a global instance, that can be used directly:
MMKV also supports Multi-Process Access. Full tutorials can be found here.
Performance
Writing random int for 10000 times, we get this chart:
For more benchmark data, please refer to our benchmark.
MMKV for Windows
Features
Efficient. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of Windows to achieve the best performance.
Multi-Process concurrency: MMKV supports concurrent read-read and read-write access between processes.
Easy-to-use. You can use MMKV as you go. All changes are saved immediately, no save, no sync calls are needed.
Small.
A handful of files: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.
About 10K in binary size: MMKV adds about 10K on application size, and much less when zipped.
Getting Started
Installation Via Source
Getting source code from git repository:
git clone https://github.com/Tencent/MMKV.git
Add Core/core.vcxproj to your solution;
Add MMKV project to your project's dependencies;
Add $(OutDir)include to your project's C/C++ -> General -> Additional Include Directories;
Add $(OutDir) to your project's Linker -> General -> Additional Library Directories;
Add mmkv.lib to your project's Linker -> Input -> Additional Dependencies;
Add #include <MMKV/MMKV.h> to your source file and we are done.
note:
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.
MMKV is developed with Visual Studio 2017, change the Platform Toolset if you use a different version of Visual Studio.
You can use MMKV as you go. All changes are saved immediately, no sync, no save calls needed.
Setup MMKV on App startup, say in your main(), add these lines:
MMKV also supports Multi-Process Access. Full tutorials can be found here Windows Tutorial.
MMKV for POSIX
Features
Efficient. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of POSIX to achieve the best performance.
Multi-Process concurrency: MMKV supports concurrent read-read and read-write access between processes.
Easy-to-use. You can use MMKV as you go. All changes are saved immediately, no save, no sync calls are needed.
Small.
A handful of files: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.
About 7K in binary size: MMKV adds about 7K on application size, and much less when zipped.
You can use MMKV as you go. All changes are saved immediately, no sync, no save calls needed.
Setup MMKV on App startup, say in your main(), add these lines:
MMKV also supports Multi-Process Access. Full tutorials can be found here POSIX Tutorial.
MMKV for HarmonyOS NEXT
Features
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.
Multi-Process concurrency: MMKV supports concurrent read-read and read-write access between processes.
Easy-to-use. You can use MMKV as you go. All changes are saved immediately, no sync, no flush calls needed.
Small.
A handful of files: MMKV contains process locks, encode/decode helpers and mmap logics and nothing more. It's really tidy.
About 600K in binary size: MMKV adds about 600K per architecture on App size, and much less when zipped (HAR/HAP).
Getting Started
Installation via OHPM:
ohpm install @tencent/mmkv
Quick Tutorial
You can use MMKV as you go. All changes are saved immediately, no sync, no apply calls needed.
Setup MMKV on App startup, say your EntryAbility.onCreate() function, add these lines:
To give clarity of what is expected of our members, MMKV has adopted the code of conduct defined by the Contributor Covenant, which is widely used. And we think it articulates our values well. For more, check out the Code of Conduct.
FAQ & Feedback
Check out the FAQ first. Should there be any questions, don't hesitate to create issues.