-
Notifications
You must be signed in to change notification settings - Fork 473
[Android] Make db size configurable #98
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
Conversation
Hey @alexkuttig, thanks for your input. Like we pointed in discussion, Async Storage has been limited to 6MB by original authros, to avoid data loss (checkout this comment). I believe this is a nice feature to have and use, if you know what potential consequences are. We can go ahead and add it, but first, let's document it well. Can I ask you to do some more work here?
Let me know what you think. thanks. |
Hi @krizzu, thanks for your feedback. I added the documentation for this feature. Feedback or change requests welcome :-) Best, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
I've left my picky notes, please let me know what you think.
thanks.
@@ -0,0 +1,25 @@ | |||
# Increase AsyncStorage Database Size on Android | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put here sections for platforms, i.e use H2 for Android
and below iOS
(which is not supported for now).
Co-Authored-By: Krzysztof Borowy <krizzu.dev@gmail.com>
Co-Authored-By: Krzysztof Borowy <krizzu.dev@gmail.com>
Co-Authored-By: Krzysztof Borowy <krizzu.dev@gmail.com>
Co-Authored-By: Krzysztof Borowy <krizzu.dev@gmail.com>
Co-Authored-By: Krzysztof Borowy <krizzu.dev@gmail.com>
Co-Authored-By: Krzysztof Borowy <krizzu.dev@gmail.com>
Thanks for your feedback! I added your request changes. |
@alexkuttig Did you see my comment here? |
@@ -59,7 +59,8 @@ getData = async () => { | |||
|
|||
``` | |||
|
|||
See docs for [api and more examples](docs/API.md), and [brownfield integration guide](docs/AdvancedUsage.md). | |||
### Advanced | |||
See docs for [api and more examples](docs/API.md) or [advanced usages](docs/advanced). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the link here still correct?
@@ -18,12 +18,24 @@ | |||
import java.util.List; | |||
|
|||
public class AsyncStoragePackage implements ReactPackage { | |||
|
|||
long mSize = 6L * 1024L * 1024L; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
?
docs/advanced/IncreaseDbSize.md
Outdated
to | ||
|
||
``` | ||
new AsyncStorage(100L * 1024L * 1024L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bad practice to pass parameters to getPackages
. It will also prevent autolinking available in RN 0.60 to work with this package. Please move the initialization logic to JS, something like:
// helpers/Storage.js
import {createAsyncStorage} from '@react-native-community/async-storage';
const AsyncStorage = createAsyncStorage(100 * 1024 * 1024);
export default AsyncStorage;
Thanks @thymikee for pointing this out. I spoke with @Salakar and he explained me what's happening with auto-linking. Although, I'm not happy with configuring DB size from JS (especially that it's one platform related), but I've got an idea on how to work around this (@Salakar's suggestion™). @alexkuttig I'll come back to you with necessary changes we have to do in order to get it working on new auto-linking feature (which will be backward compatible). thanks |
@alexkuttig Auto-linking feature will not provide a way for devs to pass an argument to the Package constructor anymore (so we cannot pass new DB size like in your example). To work around this, let's use To get this working, we need to change where the default value comes from in I've implemented this in my fork. So end user will just have to modify their Let me know if you need any help. thanks |
@krizzu @Salakar FYI I just realized (thanks to @grabbou finally providing documentation for the CLI config :P) that we have a So technically this should be possible even though a bit cumbersome (and there are slight differences in configuration for pre RN 0.60). But still I wouldn't encourage such practices, it's more of an escape hatch for existing solutions. If the package can be zero or almost config, let's keep it that way. |
@thymikee Like you said, this would be more cumbersome than just adding a value in |
Hey guys, thanks for your feedback. |
@alexkuttig I don't want your contribution to get lost, so please make changes in your current PR or close this one and open new one with docs and new implementation. Thanks. |
Thats very kind of you. I made a new pull request (#99 ) |
Summary:
Since I do need a larger max db size, I added an optional size parameter to the package constructor. This makes the maximum db size configurable, while keeping the standard size of 6L * 1024L * 1024L when not giving any value. (like discussed in ##83)
Test Plan:
1.) create async storage in MainApplication.java of the test app with new AsyncStoragePackage()
2.) write > 6MB data to async storage
3.) change initialization of AsyncStorage in MainApplication.java to new AsyncStoragePackage(100L * 1024L * 1024L)
4.) write additional data