Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Why is it recommended to re-use the same instance throughout the entire app? #594

Closed
techgerm opened this issue Oct 30, 2023 · 2 comments

Comments

@techgerm
Copy link

After reading through the differences between react-native-mmkv and react-native-mmk-storage (detailed in this thread), I've chosen react-native-mmkv for my next project but there's a stark difference that seems rather important:

In the react-native-mmkv docs, It is recommended that you re-use this instance throughout your entire app instead of creating a new instance each time, so export the storage object.

But in react-native-mmkv-storgage, it's recommended that you create separate instances per module for better performance since each database instance is small instead of a single bulky database which makes things slower as it grows.

Link here: https://rnmmkv.vercel.app/#/?id=create-unlimited-database-instances

So for this library, if the recommendation is a single instance then does that mean a single bulky database which makes things slower as it grows is not a problem here?

Thanks in advance for your response!

@mrousavy
Copy link
Owner

Hey, it will be faster since it is all in memory in one instance.

It depends on your use-case, but I'd be interested in seeing performance differences if you do a perf comparison!

@techgerm
Copy link
Author

techgerm commented Nov 1, 2023

@mrousavy okay thanks for the quick response!

@techgerm techgerm closed this as completed Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants