सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
MMKV चीवाई द्वारा विकसित एक उच्च प्रदर्शन, हल्के आकार के मूल्य-मूल्य संग्रहण समाधान है जो मोबाइल एप्लिकेशन के लिए डिज़ाइन किया गया है। यह Android, iOS, macOS, Windows और Linux प्लेटफॉर्म पर प्रभावी डेटा स्थायित्व प्रदान करता है। गति और विश्वसनीयता के लिए डिज़ाइन किया गया, MMKV मेमोरी-मैप्ड फाइल्स का उपयोग करके तेज़ पढ़ने/लिखने ऑपरेशन प्रदान करता है, जिससे यह उपयोगकर्ता प्राथमिकताओं, सत्र टोकन या कैश किए गए सामग्री जैसे छोटे से मध्यम आकार के डेटा को स्टोर करने के लिए आदर्श है। इसका क्रॉस-प्लेटफॉर्म समर्थन उपकरणों के बीच सुसंगत व्यवहार सुनिश्चित करता है। Flutter प्लगइन कम बॉयलरप्लेट के साथ एकीकरण को सरल बनाता है।
उपयोग
उपयोगकर्ता पसंदीदा संग्रहित करना
एप्लिकेशन डेटा को कैश करना
सत्र टोकन सहेजें
कॉन्फ़िगरेशन सेटिंग्स को बनाए रखना
छोटे पैमाने के ऐप स्थिति का प्रबंधन
मुख्य विशेषताएँ
उच्च गति का पठन/लेखन प्रदर्शन
प्लेटफॉर्म के अनुकूलता
मेमोरी-मैप्ड फ़ाइल स्टोरेज
कम स्मृति खपत
सरल API के साथ की-वैल्यू इंटरफेस
इनके लिए उपयुक्त
त्वरित स्थानीय भंडारण की आवश्यकता वाले ऐप
अक्सर डेटा के साथ एप्लिकेशन
प्रदर्शन पर ध्यान केंद्रित विकासकर्मी
हल्के स्थायित्व की आवश्यकता वाले प्रोजेक्ट
कई प्लेटफॉर्म के लिए फ्लटर ऐप्स
विचार योग्य बातें
बड़े डेटासेट के लिए उपयुक्त नहीं
सीमित प्रश्न क्षमता
सरल कुंजी-मान जोड़े के लिए सबसे अच्छा
डेटा डिफ़ॉल्ट रूप से एन्क्रिप्ट नहीं होता है
डेटा प्रकारों के हैंडलिंग के लिए मैन्युअल दस्तावेज़ आवश्यक है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
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.