中文版本请参看这里

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, Win32 and POSIX.

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, 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-static:1.1.2'

// replace "1.1.2" 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 Application class, add these lines:

public void onCreate() {

super.onCreate();

String rootDir = MMKV.initialize(this);

System.out.println("mmkv root: " + rootDir);

//……

}

MMKV has a global instance, that can be used 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 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 file, and protobuf to encode/decode values, making the most of iOS/macOS 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 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).

Getting Started

Installation Via CocoaPods:

Open terminal, cd to your project directory, run pod 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 to your source file and we are done.

For other installation options, see iOS/macOS Setup.

Quick Tutorial

You can use MMKV as you go, no configurations needed. All changes are saved immediately, no synchronize calls 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 *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 setString:@"hello, mmkv" forKey:@"string"];

NSString *str = [mmkv getStringForKey:@"string"];

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 Win32

Features

Efficient. MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values, making the most of Windows 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 save, no sync 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 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 Win32/MMKV/MMKV.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 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 vise versa.

MMKV is developed with Visual Studio 2017, change the Platform Toolset if you use a different version of Visual Studio.

For other installation options, see Win32 Setup.

Quick Tutorial

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:

#include

int main() {

std::wstring rootDir = getYourAppDocumentDir();

MMKV::initializeMMKV(rootDir);

//...

}

MMKV has a global instance, that can be used directly:

auto mmkv = MMKV::defaultMMKV();

mmkv->set(true, "bool");

std::cout << "bool = " << mmkv->getBool("bool") << std::endl;

mmkv->set(1024, "int32");

std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;

mmkv->set("Hello, MMKV for Win32", "string");

std::string result;

mmkv->getString("string", result);

std::cout << "string = " << result << std::endl;

MMKV also supports Multi-Process Access. Full tutorials can be found here Win32 Tutorial.

MMKV for POSIX

Features

Efficient. MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values, making the most of POSIX 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 save, no sync 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 7K in binary size: MMKV adds about 7K on application size, and much less when zipped.

Getting Started

Installation Via CMake

Getting source code from git repository: git clone https://github.com/Tencent/MMKV.git

Edit your CMakeLists.txt, add those lines:

add_subdirectory(mmkv/POSIX/src mmkv)

target_link_libraries(MyApp

mmkv)

Add #include "MMKV.h" to your source file and we are done.

For other installation options, see POSIX Setup.

Quick Tutorial

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:

#include "MMKV.h"

int main() {

std::string rootDir = getYourAppDocumentDir();

MMKV::initializeMMKV(rootDir);

//...

}

MMKV has a global instance, that can be used directly:

auto mmkv = MMKV::defaultMMKV();

mmkv->set(true, "bool");

std::cout << "bool = " << mmkv->getBool("bool") << std::endl;

mmkv->set(1024, "int32");

std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;

mmkv->set("Hello, MMKV for Win32", "string");

std::string result;

mmkv->getString("string", result);

std::cout << "string = " << result << std::endl;

MMKV also supports Multi-Process Access. Full tutorials can be found here POSIX Tutorial.

License

MMKV is published under the BSD 3-Clause license. For details check out the LICENSE.TXT.

Change Log

Check out the CHANGELOG.md for details of change history.

Contributing

If you are interested in contributing, check out the CONTRIBUTING.md, also join our Tencent OpenSource Plan.

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.

MMKV_MMKV - 由微信开发的高效,小巧的移动端key-value存储框架,适用于iOS和Android...相关推荐

  1. web前端开发常用的10个高端CSS UI开源框架

    随着人们对体验的极致追求,web页面设计也面临着新的挑战,不仅需要更人性化的设计理念,还需要设计出更酷炫的页面.作为web前端开发人员,运用开源资源,更快更好地实现一些现代化的界面,是必备技能之一.下 ...

  2. 微信开发接口调用(前端+.net服务端)

    微信接口开发,包含服务端(采用.net),前端js//服务端 namespace EatWorld {public partial class Default : System.Web.UI.Page ...

  3. 一款功能强大的客户端研发助手,适用于 iOS 、Android、微信小程序 !移动端开发必备...

    热文推荐: 尘埃落定!清华才子王垠加入华为职级22,前阿里P10赵海平加入字节跳动,职级或为4+ 百度网盘"破解版",Pandownload开发者被抓 DoraemonKit 简称 ...

  4. 移动端下拉刷新,兼容ios,Android及微信浏览器

    先看一下效果图 下拉效果的样子参考的新浪微博,滚动加载是ydui的滚动加载组件 因为滚动加载使用的ydui的组件,我这里便不再累述 在线体验点这里 首先分析下拉刷新是怎么实现的 1.页面滚动到顶部时, ...

  5. 移动端:判断是否微信端、判断手机操作系统(ios或android)

    http://caibaojian.com/browser-ios-or-android.htmlfunction is_weixin() { var ua = window.navigator.us ...

  6. 关于微信开发的语音存储问题

    关于微信开发有时我们可能会用到语音的接收存储功能,因此将我这一周在语音这块碰到的问题共享给大家. 微信提供的官方文档里关于接收语音这块的说明是:语音的格式Format为amr或者speex等格式,因此 ...

  7. Delphi Web前端开发教程(4):基于TMS WEB Core框架

    图 Delphi开发的即时战略游戏软件<Knights Province> 图 Delphi开发的猎鹰9火箭模拟仿真软件<Falcon 9 – First Stage Simulat ...

  8. 限时团购,6.9折:《微信开发深度解析:公众号、小程序高效开发秘籍》推荐序

    全书由目 Senparc.Weixin SDK 作者苏震巍历时 2 年完成,涵盖了开发微信公众号及小程序需要用的的各项后端开发技能.技巧.避坑提示,以及 Senparc.Weixin SDK 微信公众 ...

  9. 微信开发必看,使用.Net Core 开发微信跨平台应用

    .NET Core 是一个开源通用的开发框架,源码由微软官方和社区共同支持.支持跨平台,即支持在 Window,macOS,Linux 等系统上的开发和部署,并且可以在硬件设备,云服务,和嵌入式/物联 ...

  10. “小程序 · 云开发”重磅上线,让小程序开发更高效!

    近日,"小程序 · 云开发"解决方案正式上线,该方案可以为小程序开发者提供完整的云端支持. 通过简化复杂的后端和运维操作,让即便不具备一定后端知识的开发者,也能高效开发出一款高质量 ...

最新文章

  1. 36岁自学python_Python语言基础
  2. oracle 12.1的那些坑
  3. Markdown 如何实现空行、空格?
  4. tcp/ip ---数据封装过程
  5. 开设计算机应用基础这门学科意义,计算机应用基础与专业课程整合思考.doc
  6. python虚拟机直接加载字节码运行程序_第二章 python如何运行程序
  7. 项目实训第二周(车道线检测)
  8. java 捕获 nullpointerexception,Java 空检查链与捕获NullPointerException
  9. VS2013 产品密钥 – 所有版本
  10. nginx启动成功,web页面报错
  11. js 设置body背景图片
  12. 越是经济下行,越是赚大钱的好机会!
  13. spring中将静态代理修改为动态代理
  14. 正项级数收敛性的判别法
  15. 计算机教学问卷调查,信息技术在数学课堂教学中的应用:数学课堂信息技术应用调查问卷...
  16. Mybatis-Plus入门(一)
  17. 加快onenote同步速度
  18. 红孩儿编辑器的模块设计6
  19. 淘宝关键词搜索采集商品价格销量接口分析商品价格走势(商品列表接口,商品销量接口,商品价格接口,分类ID采集精准商品数据接口)接口代码对接流程
  20. Web前端系列技术之移动端CSDN会员页面复刻(动态完整版)

热门文章

  1. 音创linux版e100加歌,【图片】音创高清点歌机E100-3D版 火爆上市 现将资料爆出_点歌机吧_百度贴吧...
  2. Windows Phone能否第三极崛起
  3. JAVA文件传输原理及介绍—狂神说
  4. 安卓手机端、PC电脑端的微信文件存储位置:
  5. 尽量干净地卸载360
  6. NOD32企业内部更新服务器搭建
  7. java httpclient 下载_java HttpClient 下载一张图片
  8. android 刷路由器,荣耀立方WS860s路由器完整刷机包怎么使用?荣耀立方刷机图文教程...
  9. slickedit调试linux内核,SlickEdit使用(设置篇)
  10. 05笔记 离散数学——函数——基于离散数学(第3版)_章炯民,陶增乐