All Projects → mrousavy → React Native Mmkv

mrousavy / React Native Mmkv

Licence: other
⚡️ An extremely fast key/value storage library for React Native. ~30x faster than AsyncStorage!

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to React Native Mmkv

traceroute-for-android
traceroute for android
Stars: ✭ 60 (-81.01%)
Mutual labels:  jni
jni-bindgen
Generate Rust JVM FFI wrappers around APIs defined by .jar or .class files, because maintaining your own hand-written bindings is an exercise in boredom, soundness bugs, and pain.
Stars: ✭ 55 (-82.59%)
Mutual labels:  jni
Xlowpoly
Lowpoly picture, Sandpainting for Android implemented by JNI, delaunay triangulation algorithm
Stars: ✭ 271 (-14.24%)
Mutual labels:  jni
android-webrtc-aecm
An acoustic echo cancellation for android, based on webrtc aecm algorithms
Stars: ✭ 24 (-92.41%)
Mutual labels:  jni
android-PageFlip-JNI
JNI library of Page Flip
Stars: ✭ 14 (-95.57%)
Mutual labels:  jni
android-opus-codec
Implementation of Opus encoder and decoder in C++ for android with JNI
Stars: ✭ 44 (-86.08%)
Mutual labels:  jni
jvm-dump-proxy
A proxy DLL for Windows to dump JVM classes at JNI level
Stars: ✭ 53 (-83.23%)
Mutual labels:  jni
Jni.hpp
A modern, type-safe, header-only, C++14 wrapper for JNI
Stars: ✭ 313 (-0.95%)
Mutual labels:  jni
premake-android-studio
premake5 module for android-studio and gradle build.
Stars: ✭ 24 (-92.41%)
Mutual labels:  jni
Jni4android
JNI Generater for Android
Stars: ✭ 261 (-17.41%)
Mutual labels:  jni
jni
V wrapper around the C Java Native Interface
Stars: ✭ 15 (-95.25%)
Mutual labels:  jni
SignatureVerificationDemo
Android 使用jni校验应用签名sha1值,防止so文件逆向盗用
Stars: ✭ 111 (-64.87%)
Mutual labels:  jni
SecurityDemo
ndk进行简单的签名校验,密钥保护demo,android应用签名校验
Stars: ✭ 22 (-93.04%)
Mutual labels:  jni
android-openssl
OpenSSL build for Android (arm, armv7, x86)
Stars: ✭ 69 (-78.16%)
Mutual labels:  jni
Jnioor
基于C++模板函数与Fluent API设计的JNI反射库,极大的简化JNI反射调用,提高JNI开发效率与稳定性
Stars: ✭ 278 (-12.03%)
Mutual labels:  jni
narcissus
A library for bypassing all of Java's security mechanisms, visibility checks, and encapsulation measures via the JNI API
Stars: ✭ 27 (-91.46%)
Mutual labels:  jni
sbt-jni
SBT Plugin to ease working with JNI
Stars: ✭ 110 (-65.19%)
Mutual labels:  jni
Javacpp
The missing bridge between Java and native C++
Stars: ✭ 3,703 (+1071.84%)
Mutual labels:  jni
Androidp7zip
An Android compress and extract library support popular compression format such as rar, zip, tar, lzma. based on p7zip.
Stars: ✭ 289 (-8.54%)
Mutual labels:  jni
JavaCAN
A simple JNI wrapper for the socketcan API provided by the Linux kernel. As it is wrapping a Linux Kernel API, it is intended for use on Linux only.
Stars: ✭ 23 (-92.72%)
Mutual labels:  jni

MMKV


MMKV is an efficient, small mobile key-value storage framework developed by WeChat.

See Tencent/MMKV for more information

react-native-mmkv is a library that allows you to use MMKV inside your React Native applications.

Features

  • Get and set strings, booleans and numbers
  • Fully synchronous calls, no async/await, no Promises, no Bridge.
  • High performance because everything is written in C++ (even the JS functions have C++ bodies!)
  • ~30x faster than AsyncStorage
  • Uses JSI instead of the "old" Bridge

Fun fact: since all the JS functions have C++ implementations, you can also directly call them in reanimated worklets, Vision Camera frame processors or custom threads using react-native-multithreading.

Benchmark

AsyncStorage vs MMKV: Reading a value from Storage 1000 times.
Measured in milliseconds on an iPhone 8, lower is better.

Installation

npm install react-native-mmkv
cd ios && pod install

Usage

Set

import { MMKV } from 'react-native-mmkv';

MMKV.set('user.name', 'Marc')
MMKV.set('user.age', 20)
MMKV.set('is-mmkv-fast-asf', true)

Get

import { MMKV } from 'react-native-mmkv';

const username = MMKV.getString('user.name') // 'Marc'
const age = MMKV.getNumber('user.age') // 20
const isMmkvFastAsf = MMKV.getBoolean('is-mmkv-fast-asf') // true

Delete

import { MMKV } from 'react-native-mmkv';

MMKV.delete('user.name')

Get all keys

import { MMKV } from 'react-native-mmkv';

const keys = MMKV.getAllKeys() // ['user.name', 'user.age', 'is-mmkv-fast-asf']

Objects

import { MMKV } from 'react-native-mmkv';

const user = {
  username: 'Marc',
  age: 20
}

MMKV.set('user', JSON.stringify(user))

const jsonUser = MMKV.getString('user') // { 'username': 'Marc', 'age': 20 }
const userObject = JSON.parse(jsonUser)

Limitations

As the library uses JSI for synchronous native methods access, remote debugging (e.g. with Chrome) is no longer possible. Instead, you should use Flipper.

redux-persist

If you want to use MMKV with redux-persist, create the following storage object:

import { MMKV } from "react-native-mmkv";
import { Storage } from "redux-persist";

// Unfortunately redux-persist expects Promises,
// so we have to wrap our sync calls with Promise resolvers/rejecters
export const storage: Storage = {
  setItem: (key: string, value: string): Promise<boolean> => {
    MMKV.set(key, value);
    return Promise.resolve(true);
  },
  getItem: (key: string): Promise<string> => {
    const value = MMKV.getString(key);
    return Promise.resolve(value);
  },
  removeItem: (key: string): Promise<void> => {
    MMKV.delete(key);
    return Promise.resolve();
  },
};

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].