Skip to content

Commit

Permalink
Merge pull request #1455 from Tencent/hotfix_64bit_readme
Browse files Browse the repository at this point in the history
update requirement for 64-bit arch on home page
  • Loading branch information
lingol authored Dec 13, 2024
2 parents f08b3ba + 39976e6 commit 820c425
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 101 deletions.
128 changes: 65 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ dependencies {
}
```

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.

For other installation options, see [Android Setup](https://github.com/Tencent/MMKV/wiki/android_setup).

### Quick Tutorial
Expand Down Expand Up @@ -270,69 +272,69 @@ std::cout << "string = " << result << std::endl;
```
MMKV also supports **Multi-Process Access**. Full tutorials can be found here [POSIX Tutorial](https://github.com/Tencent/MMKV/wiki/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:
```bash
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:

```js
import { MMKV } from '@tencent/mmkv';

export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
let appCtx = this.context.getApplicationContext();
let mmkvRootDir = MMKV.initialize(appCtx);
console.info('mmkv rootDir: ', mmkvRootDir);
……
}
```
MMKV has a global instance, that can be used directly:
```js
import { MMKV } from '@tencent/mmkv';

let mmkv = MMKV.defaultMMKV();
mmkv.encodeBool('bool', true);
console.info('bool = ', mmkv.decodeBool('bool'));

mmkv.encodeInt32('int32', Math.pow(2, 31) - 1);
console.info('max int32 = ', mmkv.decodeInt32('int32'));

mmkv.encodeInt64('int', BigInt(2**63) - BigInt(1));
console.info('max int64 = ', mmkv.decodeInt64('int'));

let str: string = 'Hello OpenHarmony from MMKV';
mmkv.encodeString('string', str);
console.info('string = ', mmkv.decodeString('string'));

let arrayBuffer: ArrayBuffer = StringToArrayBuffer('Hello OpenHarmony from MMKV with bytes');
mmkv.encodeBytes('bytes', arrayBuffer);
let bytes = mmkv.decodeBytes('bytes');
console.info('bytes = ', ArrayBufferToString(bytes));
```
As you can see, MMKV is quite easy to use.
# 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:
```bash
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:

```js
import { MMKV } from '@tencent/mmkv';

export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
let appCtx = this.context.getApplicationContext();
let mmkvRootDir = MMKV.initialize(appCtx);
console.info('mmkv rootDir: ', mmkvRootDir);
……
}
```
MMKV has a global instance, that can be used directly:
```js
import { MMKV } from '@tencent/mmkv';

let mmkv = MMKV.defaultMMKV();
mmkv.encodeBool('bool', true);
console.info('bool = ', mmkv.decodeBool('bool'));

mmkv.encodeInt32('int32', Math.pow(2, 31) - 1);
console.info('max int32 = ', mmkv.decodeInt32('int32'));

mmkv.encodeInt64('int', BigInt(2**63) - BigInt(1));
console.info('max int64 = ', mmkv.decodeInt64('int'));

let str: string = 'Hello OpenHarmony from MMKV';
mmkv.encodeString('string', str);
console.info('string = ', mmkv.decodeString('string'));

let arrayBuffer: ArrayBuffer = StringToArrayBuffer('Hello OpenHarmony from MMKV with bytes');
mmkv.encodeBytes('bytes', arrayBuffer);
let bytes = mmkv.decodeBytes('bytes');
console.info('bytes = ', ArrayBufferToString(bytes));
```
As you can see, MMKV is quite easy to use.
For the full documentation, see [HarmonyOS NEXT Tutorial](https://github.com/Tencent/MMKV/wiki/ohos_setup).
## License
Expand Down
77 changes: 39 additions & 38 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
// replace "2.0.1" with any available version
}
```
从 v2.0.0 起, MMKV **去掉了 32-bit 架构的支持**、API level 22 及以下的支持, 如有这类需求,请使用 v1.3.x LTS 版本。
更多安装指引参考 [Android Setup](https://github.com/Tencent/MMKV/wiki/android_setup_cn)

### 快速上手
Expand Down Expand Up @@ -226,60 +227,60 @@ std::cout << "string = " << result << std::endl;
```
MMKV 支持**多进程访问**,更详细的用法参考 [POSIX Tutorial](https://github.com/Tencent/MMKV/wiki/posix_tutorial_cn)。
## HarmonyOS NEXT 指南
### 安装引入
推荐使用 OHPM:
```bash
ohpm install @tencent/mmkv
```
```bash
ohpm install @tencent/mmkv
```

更多安装指引参考 [HarmonyOS NEXT Tutorial](https://github.com/Tencent/MMKV/wiki/ohos_setup)

### 快速上手
MMKV 的使用非常简单,所有变更立马生效,无需调用 `save``sync`
在 App 启动时初始化 MMKV,设定 MMKV 的根目录,例如在 `EntryAbility.onCreate()` 里:

```js
import { MMKV } from '@tencent/mmkv';

export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
let appCtx = this.context.getApplicationContext();
let mmkvRootDir = MMKV.initialize(appCtx);
console.info('mmkv rootDir: ', mmkvRootDir);
……
}
```
```js
import { MMKV } from '@tencent/mmkv';

export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
let appCtx = this.context.getApplicationContext();
let mmkvRootDir = MMKV.initialize(appCtx);
console.info('mmkv rootDir: ', mmkvRootDir);
……
}
```
MMKV 提供一个全局的实例,可以直接使用:
```js
import { MMKV } from '@tencent/mmkv';

let mmkv = MMKV.defaultMMKV();
mmkv.encodeBool('bool', true);
console.info('bool = ', mmkv.decodeBool('bool'));

mmkv.encodeInt32('int32', Math.pow(2, 31) - 1);
console.info('max int32 = ', mmkv.decodeInt32('int32'));

mmkv.encodeInt64('int', BigInt(2**63) - BigInt(1));
console.info('max int64 = ', mmkv.decodeInt64('int'));

let str: string = 'Hello OpenHarmony from MMKV';
mmkv.encodeString('string', str);
console.info('string = ', mmkv.decodeString('string'));

let arrayBuffer: ArrayBuffer = StringToArrayBuffer('Hello OpenHarmony from MMKV with bytes');
mmkv.encodeBytes('bytes', arrayBuffer);
let bytes = mmkv.decodeBytes('bytes');
console.info('bytes = ', ArrayBufferToString(bytes));
```js
import { MMKV } from '@tencent/mmkv';

let mmkv = MMKV.defaultMMKV();
mmkv.encodeBool('bool', true);
console.info('bool = ', mmkv.decodeBool('bool'));

mmkv.encodeInt32('int32', Math.pow(2, 31) - 1);
console.info('max int32 = ', mmkv.decodeInt32('int32'));

mmkv.encodeInt64('int', BigInt(2**63) - BigInt(1));
console.info('max int64 = ', mmkv.decodeInt64('int'));

let str: string = 'Hello OpenHarmony from MMKV';
mmkv.encodeString('string', str);
console.info('string = ', mmkv.decodeString('string'));

let arrayBuffer: ArrayBuffer = StringToArrayBuffer('Hello OpenHarmony from MMKV with bytes');
mmkv.encodeBytes('bytes', arrayBuffer);
let bytes = mmkv.decodeBytes('bytes');
console.info('bytes = ', ArrayBufferToString(bytes));
```
MMKV 更详细的用法参考 [HarmonyOS NEXT Tutorial](https://github.com/Tencent/MMKV/wiki/ohos_setup)。
## License
MMKV 以 BSD 3-Clause 证书开源,详情参见 [LICENSE.TXT](./LICENSE.TXT)。
Expand Down

0 comments on commit 820c425

Please sign in to comment.