

GitHub - Tencent/MMKV: An efficient, samll mobile key-value storage framework de...
source link: https://github.com/Tencent/MMKV
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

readme.md
中文版本请参看这里
MMKV is an efficient, small, easy-to-use mobile key-value storage framework used in the WeChat application. It's currently available on both iOS and Android.
MMKV for iOS
Features
-
Efficient. MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values, making the most of iOS to achieve best performance.
-
Easy-to-use. You can use MMKV as you go, no configurations needed. All changes are saved immediately, no
synchronize
calls needed. -
Small
- A handful 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).
Getting Started
Installation Via CocoaPods:
- Install CocoaPods;
- Open terminal,
cd
to your project directory, runpod repo update
to make CocoaPods aware of the latest available MMKV versions; - Edit your Podfile, add
pod 'MMKV'
to your app target; - Run
pod install
; - Open the
.xcworkspace
file generated by CocoaPods; - Add
#import <MMKV/MMKV.h>
to your source file and we are done.
For other installation options, see iOS Setup.
Quick Tutorial
You can use MMKV as you go, no configurations needed. All changes are saved immediately, no synchronize
calls needed.
MMKV *mmkv = [MMKV defaultMMKV]; [mmkv setBool:YES forKey:@"bool"]; BOOL bValue = [mmkv getBoolForKey:@"bool"]; [mmkv setInt32:-1024 forKey:@"int32"]; int32_t iValue = [mmkv getInt32ForKey:@"int32"]; [mmkv setObject:@"hello, mmkv" forKey:@"string"]; NSString *str = [mmkv getObjectOfClass:NSString.class forKey:@"string"];
Full tutorials can be found here.
Performence
Writing random int
for 10000 times, we get this chart:
For more benchmark data, please refer to our benchmark.
MMKV for Android
Features
-
Efficient. MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values, making the most of Android 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
, noapply
calls needed. -
Small.
- A handful files: MMKV contains process locks, encode/decode helpers and mmap logics and nothing more. It's really tidy.
- About 60K in binary size: MMKV adds about 60K 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:1.0.10' // replace "1.0.10" with any available version }
For other installation options, see Android Setup.
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 MainActivity
, add these code:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String rootDir = MMKV.initialize(this); System.out.println("mmkv root: " + rootDir); //…… }
MMKV has a global instance, you can use it directly:
import com.tencent.mmkv.MMKV; MMKV kv = MMKV.defaultMMKV(); kv.encode("bool", true); boolean bValue = kv.decodeBool("bool"); kv.encode("int", Integer.MIN_VALUE); int iValue = kv.decodeInt("int"); kv.encode("string", "Hello from mmkv"); String str = kv.decodeString("string");
MMKV also supports Multi-Process Access. Full tutorials is here Android Tutorial.
Performence
Writing random int
for 1000 times, we get this chart:
For more benchmark data, please refer to our benchmark.
License
MMKV is published under the BSD 3-Clause license. For details check out the LICENSE.TXT.
Contributing
If you are interested in contributing, check out the CONTRIBUTING.md, also join our Tencent OpenSource Plan.
FAQ & Feedback
Check out the FAQ first. Should there be any questions, don't hesitate to create issuses.
Recommend
-
192
ReadMe.md Biny是一款高性能的轻...
-
171
项目目前是存档状态,感谢您对腾讯开源项目的关注!您可以继续fork后更新迭代,感谢理解和支持;如果您有其他疑问,建议请发送邮件:[email protected] 与我们联系 Tencent Serv...
-
43
README.md FAutoTest 一个 H5、小程序自动化测试框架 简介 随着产品业务形态逐渐从 App 延升到微信小程序、微信公众...
-
35
README.md NoahV 简体中文 | English
-
37
At this year's Open Source Summit in San Diego, California, Jim Zemlin, executive director of the Linux Foundation, gave a keynote speech. He defined TARS, a microservice RPC framework that was open sourced by Tencent and...
-
13
A more gas-efficient upgradeable proxy by not using storage Automate your Ethereum operations with OpenZeppelin Defender —
-
40
This Alibaba, Tencent backed mobile game veteran is another Chinese studio to go public, and aboard- PingWestThis Alibaba, Tencent backed mobile game veteran is another Chinese studio to go public, and aboard
-
7
Magnetic Phenomena Discovery Paves Way to Faster and More Efficient Data Storage TOPICS:University of Konstanz By University of Konstanz September 4, 202...
-
11
Efficient storage and retrieval of two-dimensional data in the JVM database advertisements I need to store 2 di...
-
6
Android 13 launch devices will use Huawei’s EROFS for fast, efficient storage use
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK