{"id":14956344,"url":"https://github.com/tencent/mmkv","last_synced_at":"2025-09-09T19:53:05.716Z","repository":{"id":37412504,"uuid":"149111813","full_name":"Tencent/MMKV","owner":"Tencent","description":"An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, POSIX, and OHOS.","archived":false,"fork":false,"pushed_at":"2025-05-12T12:34:50.000Z","size":47545,"stargazers_count":17912,"open_issues_count":1,"forks_count":1935,"subscribers_count":283,"default_branch":"master","last_synced_at":"2025-05-13T11:06:46.812Z","etag":null,"topics":["android","flutter","golang","ios","key-value","kotlin","macos","ohos","python","swift","tvos","visionos","watchos","wechat","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tencent.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.TXT","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["lingol"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2018-09-17T10:59:36.000Z","updated_at":"2025-05-13T09:48:49.000Z","dependencies_parsed_at":"2022-07-14T09:22:20.453Z","dependency_job_id":"56133b42-4af6-49ac-9965-fe0a125f8a0e","html_url":"https://github.com/Tencent/MMKV","commit_stats":{"total_commits":1203,"total_committers":51,"mean_commits":23.58823529411765,"dds":0.1296758104738155,"last_synced_commit":"b154a2387605646fcea07b1a2f36cbe8a6fc185a"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FMMKV","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FMMKV/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FMMKV/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FMMKV/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tencent","download_url":"https://codeload.github.com/Tencent/MMKV/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253929364,"owners_count":21985802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","flutter","golang","ios","key-value","kotlin","macos","ohos","python","swift","tvos","visionos","watchos","wechat","windows"],"created_at":"2024-09-24T13:12:49.617Z","updated_at":"2025-09-09T19:53:05.697Z","avatar_url":"https://github.com/Tencent.png","language":"C++","readme":"[![license](https://img.shields.io/badge/license-BSD_3-brightgreen.svg?style=flat)](https://github.com/Tencent/MMKV/blob/master/LICENSE.TXT)\r\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/MMKV/pulls)\r\n[![Release Version](https://img.shields.io/badge/release-2.2.3-brightgreen.svg)](https://github.com/Tencent/MMKV/releases)\r\n[![Platform](https://img.shields.io/badge/Platform-%20Android%20%7C%20iOS%2FmacOS%20%7C%20Windows%20%7C%20POSIX%20%7C%20HarmonyOS%20NEXT-brightgreen.svg)](https://github.com/Tencent/MMKV/wiki/home)\r\n\r\n中文版本请参看[这里](./README_CN.md)\r\n\r\nMMKV 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**.\r\n\r\n# MMKV for Android\r\n\r\n## Features\r\n\r\n* **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.\r\n  * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.\r\n\r\n* **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `sync`, no `apply` calls needed.\r\n\r\n* **Small**.\r\n  * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.\r\n  * **About 50K in binary size**: MMKV adds about 50K per architecture on App size, and much less when zipped (APK).\r\n\r\n\r\n## Getting Started\r\n\r\n### Installation Via Maven\r\nAdd the following lines to `build.gradle` on your app module:\r\n\r\n```gradle\r\ndependencies {\r\n    implementation 'com.tencent:mmkv:2.2.3'\r\n    // replace \"2.2.3\" with any available version\r\n}\r\n```\r\n\r\nStarting 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.  \r\n\r\nFor other installation options, see [Android Setup](https://github.com/Tencent/MMKV/wiki/android_setup).\r\n\r\n### Quick Tutorial\r\nYou can use MMKV as you go. All changes are saved immediately, no `sync`, no `apply` calls needed.  \r\nSetup MMKV on App startup, say your `Application` class, add these lines:\r\n\r\n```Java\r\npublic void onCreate() {\r\n    super.onCreate();\r\n\r\n    String rootDir = MMKV.initialize(this);\r\n    System.out.println(\"mmkv root: \" + rootDir);\r\n    //……\r\n}\r\n```\r\n\r\nMMKV has a global instance, that can be used directly:\r\n\r\n```Java\r\nimport com.tencent.mmkv.MMKV;\r\n    \r\nMMKV kv = MMKV.defaultMMKV();\r\n\r\nkv.encode(\"bool\", true);\r\nboolean bValue = kv.decodeBool(\"bool\");\r\n\r\nkv.encode(\"int\", Integer.MIN_VALUE);\r\nint iValue = kv.decodeInt(\"int\");\r\n\r\nkv.encode(\"string\", \"Hello from mmkv\");\r\nString str = kv.decodeString(\"string\");\r\n```\r\n\r\nMMKV also supports **Multi-Process Access**. Full tutorials can be found here [Android Tutorial](https://github.com/Tencent/MMKV/wiki/android_tutorial).\r\n\r\n## Performance\r\nWriting random `int` for 1000 times, we get this chart:  \r\n![](https://github.com/Tencent/MMKV/wiki/assets/profile_android_mini.png)  \r\nFor more benchmark data, please refer to [our benchmark](https://github.com/Tencent/MMKV/wiki/android_benchmark).\r\n\r\n# MMKV for iOS/macOS\r\n\r\n## Features\r\n\r\n* **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.\r\n \r\n* **Easy-to-use**. You can use MMKV as you go, no configurations are needed. All changes are saved immediately, no `synchronize` calls are needed.\r\n\r\n* **Small**.\r\n  * **A handful of files**: MMKV contains encode/decode helpers and mmap logics and nothing more. It's really tidy.\r\n  * **Less than 30K in binary size**: MMKV adds less than 30K per architecture on App size, and much less when zipped (IPA).\r\n\r\n## Getting Started\r\n\r\n### Installation Via CocoaPods:\r\n  1. Install [CocoaPods](https://guides.CocoaPods.org/using/getting-started.html);\r\n  2. Open the terminal, `cd` to your project directory, run `pod repo update` to make CocoaPods aware of the latest available MMKV versions;\r\n  3. Edit your Podfile, add `pod 'MMKV'` to your app target;\r\n  4. Run `pod install`;\r\n  5. Open the `.xcworkspace` file generated by CocoaPods;\r\n  6. Add `#import \u003cMMKV/MMKV.h\u003e` to your source file and we are done.\r\n\r\nFor other installation options, see [iOS/macOS Setup](https://github.com/Tencent/MMKV/wiki/iOS_setup).\r\n\r\n### Quick Tutorial\r\nYou can use MMKV as you go, no configurations are needed. All changes are saved immediately, no `synchronize` calls are needed.\r\nSetup MMKV on App startup, in your `-[MyApp application: didFinishLaunchingWithOptions:]`, add these lines:\r\n\r\n```objective-c\r\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\r\n    // init MMKV in the main thread\r\n    [MMKV initializeMMKV:nil];\r\n\r\n    //...\r\n    return YES;\r\n}\r\n```\r\n\r\nMMKV has a global instance, that can be used directly:\r\n\r\n```objective-c\r\nMMKV *mmkv = [MMKV defaultMMKV];\r\n    \r\n[mmkv setBool:YES forKey:@\"bool\"];\r\nBOOL bValue = [mmkv getBoolForKey:@\"bool\"];\r\n    \r\n[mmkv setInt32:-1024 forKey:@\"int32\"];\r\nint32_t iValue = [mmkv getInt32ForKey:@\"int32\"];\r\n    \r\n[mmkv setString:@\"hello, mmkv\" forKey:@\"string\"];\r\nNSString *str = [mmkv getStringForKey:@\"string\"];\r\n```\r\n\r\nMMKV also supports **Multi-Process Access**. Full tutorials can be found [here](https://github.com/Tencent/MMKV/wiki/iOS_tutorial).\r\n\r\n## Performance\r\nWriting random `int` for 10000 times, we get this chart:  \r\n![](https://github.com/Tencent/MMKV/wiki/assets/profile_mini.png)  \r\nFor more benchmark data, please refer to [our benchmark](https://github.com/Tencent/MMKV/wiki/iOS_benchmark).\r\n\r\n\r\n# MMKV for Windows\r\n\r\n## Features\r\n\r\n* **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.\r\n  * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.\r\n\r\n* **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `save`, no `sync` calls are needed.\r\n\r\n* **Small**.\r\n  * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.\r\n  * **About 10K in binary size**: MMKV adds about 10K on application size, and much less when zipped.\r\n\r\n\r\n## Getting Started\r\n\r\n### Installation Via Source\r\n1. Getting source code from git repository:\r\n  \r\n   ```\r\n   git clone https://github.com/Tencent/MMKV.git\r\n   ```\r\n  \r\n2. Add `Core/core.vcxproj` to your solution;\r\n3. Add `MMKV` project to your project's dependencies;\r\n4. Add `$(OutDir)include` to your project's `C/C++` -\u003e `General` -\u003e `Additional Include Directories`;\r\n5. Add `$(OutDir)` to your project's `Linker` -\u003e `General` -\u003e `Additional Library Directories`;\r\n6. Add `mmkv.lib` to your project's `Linker` -\u003e `Input` -\u003e `Additional Dependencies`;\r\n7. Add `#include \u003cMMKV/MMKV.h\u003e` to your source file and we are done.\r\n\r\n\r\nnote:  \r\n\r\n1. 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++` -\u003e `Code Generation` -\u003e `Runtime Library`), or vice versa.\r\n2. MMKV is developed with Visual Studio 2017, change the `Platform Toolset` if you use a different version of Visual Studio.\r\n\r\nFor other installation options, see [Windows Setup](https://github.com/Tencent/MMKV/wiki/windows_setup).\r\n\r\n### Quick Tutorial\r\nYou can use MMKV as you go. All changes are saved immediately, no `sync`, no `save` calls needed.  \r\nSetup MMKV on App startup, say in your `main()`, add these lines:\r\n\r\n```C++\r\n#include \u003cMMKV/MMKV.h\u003e\r\n\r\nint main() {\r\n    std::wstring rootDir = getYourAppDocumentDir();\r\n    MMKV::initializeMMKV(rootDir);\r\n    //...\r\n}\r\n```\r\n\r\nMMKV has a global instance, that can be used directly:\r\n\r\n```C++\r\nauto mmkv = MMKV::defaultMMKV();\r\n\r\nmmkv-\u003eset(true, \"bool\");\r\nstd::cout \u003c\u003c \"bool = \" \u003c\u003c mmkv-\u003egetBool(\"bool\") \u003c\u003c std::endl;\r\n\r\nmmkv-\u003eset(1024, \"int32\");\r\nstd::cout \u003c\u003c \"int32 = \" \u003c\u003c mmkv-\u003egetInt32(\"int32\") \u003c\u003c std::endl;\r\n\r\nmmkv-\u003eset(\"Hello, MMKV for Windows\", \"string\");\r\nstd::string result;\r\nmmkv-\u003egetString(\"string\", result);\r\nstd::cout \u003c\u003c \"string = \" \u003c\u003c result \u003c\u003c std::endl;\r\n```\r\n\r\nMMKV also supports **Multi-Process Access**. Full tutorials can be found here [Windows Tutorial](https://github.com/Tencent/MMKV/wiki/windows_tutorial).\r\n\r\n# MMKV for POSIX\r\n\r\n## Features\r\n\r\n* **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.\r\n  * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.\r\n\r\n* **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `save`, no `sync` calls are needed.\r\n\r\n* **Small**.\r\n  * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.\r\n  * **About 7K in binary size**: MMKV adds about 7K on application size, and much less when zipped.\r\n\r\n\r\n## Getting Started\r\n\r\n### Installation Via CMake\r\n1. Getting source code from the git repository:\r\n  \r\n   ```\r\n   git clone https://github.com/Tencent/MMKV.git\r\n   ```\r\n2. Edit your `CMakeLists.txt`, add those lines:\r\n\r\n    ```cmake\r\n    add_subdirectory(mmkv/POSIX/src mmkv)\r\n    target_link_libraries(MyApp\r\n        mmkv)\r\n    ```\r\n3. Add `#include \"MMKV.h\"` to your source file and we are done.\r\n\r\nFor other installation options, see [POSIX Setup](https://github.com/Tencent/MMKV/wiki/posix_setup).\r\n\r\n### Quick Tutorial\r\nYou can use MMKV as you go. All changes are saved immediately, no `sync`, no `save` calls needed.  \r\nSetup MMKV on App startup, say in your `main()`, add these lines:\r\n\r\n```C++\r\n#include \"MMKV.h\"\r\n\r\nint main() {\r\n    std::string rootDir = getYourAppDocumentDir();\r\n    MMKV::initializeMMKV(rootDir);\r\n    //...\r\n}\r\n```\r\n\r\nMMKV has a global instance, that can be used directly:\r\n\r\n```C++\r\nauto mmkv = MMKV::defaultMMKV();\r\n\r\nmmkv-\u003eset(true, \"bool\");\r\nstd::cout \u003c\u003c \"bool = \" \u003c\u003c mmkv-\u003egetBool(\"bool\") \u003c\u003c std::endl;\r\n\r\nmmkv-\u003eset(1024, \"int32\");\r\nstd::cout \u003c\u003c \"int32 = \" \u003c\u003c mmkv-\u003egetInt32(\"int32\") \u003c\u003c std::endl;\r\n\r\nmmkv-\u003eset(\"Hello, MMKV for Windows\", \"string\");\r\nstd::string result;\r\nmmkv-\u003egetString(\"string\", result);\r\nstd::cout \u003c\u003c \"string = \" \u003c\u003c result \u003c\u003c std::endl;\r\n```\r\n\r\nMMKV also supports **Multi-Process Access**. Full tutorials can be found here [POSIX Tutorial](https://github.com/Tencent/MMKV/wiki/posix_tutorial).\r\n\r\n# MMKV for HarmonyOS NEXT\r\n\r\n## Features\r\n\r\n* **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.\r\n  * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.\r\n\r\n* **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `sync`, no `flush` calls needed.\r\n\r\n* **Small**.\r\n  * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics and nothing more. It's really tidy.\r\n  * **About 600K in binary size**: MMKV adds about 600K per architecture on App size, and much less when zipped (HAR/HAP).\r\n\r\n\r\n## Getting Started\r\n### Installation via OHPM:\r\n\r\n```bash\r\nohpm install @tencent/mmkv\r\n```\r\n### Quick Tutorial\r\nYou can use MMKV as you go. All changes are saved immediately, no `sync`, no `apply` calls needed.  \r\nSetup MMKV on App startup, say your `EntryAbility.onCreate()` function, add these lines:\r\n\r\n```js\r\nimport { MMKV } from '@tencent/mmkv';\r\n\r\nexport default class EntryAbility extends UIAbility {\r\n  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {\r\n    let appCtx = this.context.getApplicationContext();\r\n    let mmkvRootDir = MMKV.initialize(appCtx);\r\n    console.info('mmkv rootDir: ', mmkvRootDir);\r\n    ……\r\n  }\r\n```\r\n\r\nMMKV has a global instance, that can be used directly:\r\n\r\n```js\r\nimport { MMKV } from '@tencent/mmkv';\r\n    \r\nlet mmkv = MMKV.defaultMMKV();\r\nmmkv.encodeBool('bool', true);\r\nconsole.info('bool = ', mmkv.decodeBool('bool'));\r\n    \r\nmmkv.encodeInt32('int32', Math.pow(2, 31) - 1);\r\nconsole.info('max int32 = ', mmkv.decodeInt32('int32'));\r\n    \r\nmmkv.encodeInt64('int', BigInt(2**63) - BigInt(1));\r\nconsole.info('max int64 = ', mmkv.decodeInt64('int'));\r\n    \r\nlet str: string = 'Hello OpenHarmony from MMKV';\r\nmmkv.encodeString('string', str);\r\nconsole.info('string = ', mmkv.decodeString('string'));\r\n\r\nlet arrayBuffer: ArrayBuffer = StringToArrayBuffer('Hello OpenHarmony from MMKV with bytes');\r\nmmkv.encodeBytes('bytes', arrayBuffer);\r\nlet bytes = mmkv.decodeBytes('bytes');\r\nconsole.info('bytes = ', ArrayBufferToString(bytes));\r\n```\r\n\r\nAs you can see, MMKV is quite easy to use.\r\nFor the full documentation, see [HarmonyOS NEXT Tutorial](https://github.com/Tencent/MMKV/wiki/ohos_setup).\r\n\r\n## License\r\nMMKV is published under the BSD 3-Clause license. For details check out the [LICENSE.TXT](./LICENSE.TXT).\r\n\r\n## Change Log\r\nCheck out the [CHANGELOG.md](./CHANGELOG.md) for details of change history.\r\n\r\n## Contributing\r\n\r\nIf you are interested in contributing, check out the [CONTRIBUTING.md](./CONTRIBUTING.md), also join our [Tencent OpenSource Plan](https://opensource.tencent.com/contribution). MMKV has officially joined the [Tencent Device-oriented Service Product Alliance](https://tds-union.qq.com/), working together with other alliance members to build an open and mutually beneficial frontend technology product ecosystem.\r\n\r\n\r\nTo 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](./CODE_OF_CONDUCT.md).\r\n\r\n## FAQ \u0026 Feedback\r\nCheck out the [FAQ](https://github.com/Tencent/MMKV/wiki/FAQ) first. Should there be any questions, don't hesitate to create [issues](https://github.com/Tencent/MMKV/issues).\r\n\r\n## Personal Information Protection Rules\r\nUser privacy is taken very seriously: MMKV does not obtain, collect or upload any personal information. Please refer to the [MMKV SDK Personal Information Protection Rules](https://support.weixin.qq.com/cgi-bin/mmsupportacctnodeweb-bin/pages/aY5BAtRiO1BpoHxo) for details.\r\n","funding_links":["https://github.com/sponsors/lingol"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencent%2Fmmkv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftencent%2Fmmkv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencent%2Fmmkv/lists"}