In the iOS implementation, a new dispatch queue is created on each 'set' or 'get' call, from which it switches to the main queue to call MMKV, wrapped in a try/catch block.
Inside the MMKV library, a NSData object is created, another class is used to write a single "int" value to it, then the data object is used as the "raw" value for the given key.
I haven't looked any futher but already this seems like a lot of work to set a number in memory. Is there any reason for this?
I think you are right. I was focusing on basic implementation. Now I will make the performance optimizations needed. For example using a single instance of created class for all get set methods and not create them on every call. Thanks for pointing it out.
The second thing about numbers is that its just in case you needed it for something, it is there but there are other ways to set the data too.
We are using SQLite on React Native with the JSI without writing a java or object C bridge. As a result, all operations are much faster and almost all of them don't need to Promise callback.
I don't see any reason to use this over SQLite. We can do same thing on SQLite much faster way.
The primary use of MMKV seems to be a replacement for NSUserDefaults. I agree the SQLite is probably the best solution overall, but this could be a faster alternative to anyone just using NSUserDefaults
That is true but still MMKV due to its simplicity and small size is a very fast option over AsynStorage on both android and iOS. It has been used in the WeChat app used in China for datastorage.
How does react-native-mmkv-storage store data under-the-hood?
When I was building SwiftStore - a KV store [1] for iOS, I went with LevelDB as the choice for the underlying database.
LevelDB because it's written in c++ and used widely as an embedded database. Integrating it as a static library in Objective-C is also fairly straight forward.
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 and uses c++
MMKV is a simple key-value store but the good thing is that it is fast, A custom indexer can be made for querying. However there is a method to get all the keys in the storage but its not exposed in react native side. Is that what you mean?
[+] [-] tomovo|6 years ago|reply
Inside the MMKV library, a NSData object is created, another class is used to write a single "int" value to it, then the data object is used as the "raw" value for the given key.
I haven't looked any futher but already this seems like a lot of work to set a number in memory. Is there any reason for this?
[+] [-] ammarahmed6506|6 years ago|reply
The second thing about numbers is that its just in case you needed it for something, it is there but there are other ways to set the data too.
[+] [-] sercand|6 years ago|reply
[+] [-] vivekseth|6 years ago|reply
[+] [-] ammarahmed6506|6 years ago|reply
[+] [-] c-smile|6 years ago|reply
Sciter implements what I call "an ultimate data persistence solution" - NoSQL DB integrated right into script VM.
You can open storage as:
Storage provides root object - normal script object (or array) that can be updated by normal script means: All script objects that are accessible from the storage.root are persist-able - pushed to HD on storage.close() or storage.commit();More details about architecture and implementation: https://sciter.com/data-persistence-in-sciter-database-integ...
Overall feature set is close to MongoDB (modulo sharding).
DB layer uses Konstantin Knizhnik's DyBASE pretty much as it is: http://www.garret.ru/dybase.html
[+] [-] throw03172019|6 years ago|reply
[+] [-] laex|6 years ago|reply
When I was building SwiftStore - a KV store [1] for iOS, I went with LevelDB as the choice for the underlying database.
LevelDB because it's written in c++ and used widely as an embedded database. Integrating it as a static library in Objective-C is also fairly straight forward.
[1] https://github.com/hemantasapkota/SwiftStore
[+] [-] ammarahm-ed|6 years ago|reply
[+] [-] jiofih|6 years ago|reply
[+] [-] ammarahmed6506|6 years ago|reply
[+] [-] jitl|6 years ago|reply
[+] [-] ammarahmed6506|6 years ago|reply
[+] [-] theyoungwolf|6 years ago|reply
[+] [-] ammarahmed6506|6 years ago|reply