Skip to content

Commit

Permalink
update readme for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lingol committed Jan 4, 2019
1 parent e02d5d9 commit cc6af01
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 32 deletions.
60 changes: 32 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![license](https://img.shields.io/badge/license-BSD_3-brightgreen.svg?style=flat)](https://github.com/Tencent/MMKV/blob/master/LICENSE.TXT)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/MMKV/pulls)
[![Release Version](https://img.shields.io/badge/release-1.0.15-brightgreen.svg)](https://github.com/Tencent/MMKV/releases)
[![Release Version](https://img.shields.io/badge/release-1.0.16-brightgreen.svg)](https://github.com/Tencent/MMKV/releases)
[![Platform](https://img.shields.io/badge/Platform-%20iOS%20%7C%20Android-brightgreen.svg)](https://github.com/Tencent/MMKV/wiki/home)

中文版本请参看[这里](./readme_cn.md)

MMKV is an **efficient**, **small**, **easy-to-use** mobile key-value storage framework used in the WeChat application. It's currently available on **iOS**, **macOS** and **Android**.
MMKV is an **efficient**, **small**, **easy-to-use** mobile key-value storage framework used in the WeChat application. It's currently available on **iOS**, **macOS**, **Android** and **Windows**.

# MMKV for iOS/macOS

Expand Down Expand Up @@ -75,8 +75,8 @@ Add the following lines to `build.gradle` on your app module:
```gradle
dependencies {
implementation 'com.tencent:mmkv:1.0.15'
// replace "1.0.15" with any available version
implementation 'com.tencent:mmkv:1.0.16'
// replace "1.0.16" with any available version
}
```

Expand Down Expand Up @@ -137,27 +137,36 @@ For more benchmark data, please refer to [our benchmark](https://github.com/Tenc
## Getting Started

### Installation Via Source
* Clone or Download source from GitHub;
* Add `Win32/MMKV/MMKV.vcxproj` to your solution;
* Add MMKV to your project's dependencies;
* Add `$(OutDir)` 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`;
* 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 wise versa.
* MMKV is developed with Visual Studio 2017, change the `Platform Toolset` if you use a different version of Visual Studio.
1. Getting source code from git repository:

```
git clone http://git.code.oa.com/wechat-team/mmkv.git
```

2. Add `Win32/MMKV/MMKV.vcxproj` to your solution;
3. Add `MMKV` project to your project's dependencies;
4. Add `$(OutDir)include` to your project's `C/C++` -> `General` -> `Additional Include Directories`;
5. Add `$(OutDir)` to your project's `Linker` -> `General` -> `Additional Library Directories`;
6. Add `MMKV.lib` to your project's `Linker` -> `Input` -> `Additional Dependencies`;
7. Add `#include <MMKV/MMKV.h>` to your source file and we are done.


note:

1. 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 wise versa.
2. 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 [Android Setup](https://github.com/Tencent/MMKV/wiki/android_setup).
For other installation options, see [Windows Setup](https://github.com/Tencent/MMKV/wiki/windows_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:

```C++
#include "MMKV.h"
using namespace std;
#include <MMKV/MMKV.h>

int main() {
wstring rootDir = getYourAppDocumentDir();
std::wstring rootDir = getYourAppDocumentDir();
MMKV::initializeMMKV(rootDir);
//...
}
Expand All @@ -169,23 +178,18 @@ MMKV has a global instance, that can be used directly:
auto mmkv = MMKV::defaultMMKV();

mmkv->set(true, "bool");
cout << "bool = " << mmkv->getBoolForKey("bool") << endl;
std::cout << "bool = " << mmkv->getBool("bool") << std::endl;

mmkv->set(1024, "int32");
cout << "int32 = " << mmkv->getInt32ForKey("int32") << endl;
std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;

mmkv->setStringForKey("Hello, MMKV for Win32 ", "string");
string result;
mmkv->getStringForKey("string", result);
cout << "string = " << result << 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 [Android Tutorial](https://github.com/Tencent/MMKV/wiki/android_tutorial).
## Performance
Writing random `int` for 1000 times, we get this chart:
![](https://github.com/Tencent/MMKV/wiki/assets/profile_android_mini.jpg)
For more benchmark data, please refer to [our benchmark](https://github.com/Tencent/MMKV/wiki/android_benchmark).
MMKV also supports **Multi-Process Access**. Full tutorials can be found here [Windows Tutorial](https://github.com/Tencent/MMKV/wiki/windows_tutorial).
## License
MMKV is published under the BSD 3-Clause license. For details check out the [LICENSE.TXT](./LICENSE.TXT).
Expand Down
66 changes: 62 additions & 4 deletions readme_cn.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MMKV——基于 mmap 的高性能通用 key-value 组件
MMKV 是基于 mmap 内存映射的 key-value 组件,底层序列化/反序列化使用 protobuf 实现,性能高,稳定性强。从 2015 年中至今,在 iOS 微信上使用已有近 3 年,其性能和稳定性经过了时间的验证。近期也已移植到 Android / macOS 平台,一并开源。
MMKV 是基于 mmap 内存映射的 key-value 组件,底层序列化/反序列化使用 protobuf 实现,性能高,稳定性强。从 2015 年中至今在微信上使用,其性能和稳定性经过了时间的验证。近期也已移植到 Android / macOS / Windows 平台,一并开源。


## MMKV 源起
Expand Down Expand Up @@ -59,8 +59,8 @@ NSString *str = [mmkv getStringForKey:@"string"];
```gradle
dependencies {
implementation 'com.tencent:mmkv:1.0.15'
// replace "1.0.15" with any available version
implementation 'com.tencent:mmkv:1.0.16'
// replace "1.0.16" with any available version
}
```

Expand All @@ -70,7 +70,7 @@ dependencies {
MMKV 的使用非常简单,所有变更立马生效,无需调用 `sync``apply`
在 App 启动时初始化 MMKV,设定 MMKV 的根目录(files/mmkv/),例如在 MainActivity 里:

```
```Java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Expand Down Expand Up @@ -104,6 +104,64 @@ MMKV 支持**多进程访问**,更详细的用法参考 [Android Tutorial](htt
![](https://github.com/Tencent/MMKV/wiki/assets/profile_android_mini.jpg)
更详细的性能对比参考 [Android Benchmark](https://github.com/Tencent/MMKV/wiki/android_benchmark_cn)

## Windows 指南
### 安装引入
推荐使用子工程:

1. 获取 MMKV 源码:

```
git clone http://git.code.oa.com/wechat-team/mmkv.git
```
2. 添加工程 `Win32/MMKV/MMKV.vcxproj` 到你的项目里;
3. 设置你的主工程依赖于 `MMKV` 工程;
4. 添加目录 `$(OutDir)include` 到你主工程的 `C/C++` -> `常规` -> `附加包含目录`;
5. 添加目录 `$(OutDir)` 到你主工程的 `链接器` -> `常规` -> `附加库目录`;
6. 添加 `MMKV.lib` 到你主工程的 `链接器` -> `输入` -> `附加依赖项`;
7. 添加头文件 `#include <MMKV/MMKV.h>`,就可以愉快地开始你的 MMKV 之旅了。
注意:
1. MMKV 默认使用 `MT/MTd` 运行时库来编译,如果你发现主工程的配置不一样,请修改 MMKV 的配置再编译;
2. MMKV 使用 Visual Studio 2017 开发,如果你在使用其他版本的 Visual Studio,请修改 MMKV 的`工具集`与主工程一致,再编译.
更多安装指引参考 [Windows Setup](https://github.com/Tencent/MMKV/wiki/windows_setup_cn)。
### 快速上手
MMKV 的使用非常简单,所有变更立马生效,无需调用 `save`、`sync`。
在 App 启动时初始化 MMKV,设定 MMKV 的根目录,例如在 main() 里:
```C++
#include <MMKV/MMKV.h>
int main() {
std::wstring rootDir = getYourAppDocumentDir();
MMKV::initializeMMKV(rootDir);
//...
}
```

MMKV 提供一个全局的实例,可以直接使用:

```C++
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 支持**多进程访问**,更详细的用法参考 [Windows Tutorial](https://github.com/Tencent/MMKV/wiki/windows_tutorial_cn)。
## License
MMKV 以 BSD 3-Clause 证书开源,详情参见 [LICENSE.TXT](./LICENSE.TXT)。
Expand Down

0 comments on commit cc6af01

Please sign in to comment.