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

Switch to proper robust data storage implementation #1072

Closed
jthrilly opened this issue Aug 14, 2020 · 1 comment · Fixed by #1095
Closed

Switch to proper robust data storage implementation #1072

jthrilly opened this issue Aug 14, 2020 · 1 comment · Fixed by #1095

Comments

@jthrilly
Copy link
Member

jthrilly commented Aug 14, 2020

We need to use appropriate storage adaptors for redux-persist because localStorage can be erased at any time by the OS, and has varied limits across platforms: https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html

This will lead to sudden spontaneous data loss.

It is also very slow (serialize/deserialize) and has limits on what it can represent.

Existing adapter options are listed on the redux-persist repo: https://github.com/rt2zz/redux-persist

It looks like an optimal solution would be to find a way to use SQL lite across electron and cordova. This may require writing our own plugin for cordova. Cordova plugin is here: https://github.com/storesafe/cordova-sqlite-storage

Potential plugin already developed here: https://github.com/sumedh22/redux-persist-cordova-sqlite#readme

IndexedDB, localStorage, localForage, and web SQL are all not appropriate, since they are also susceptible to OS deletion on iOS.

This relates to #1066, and will ideally contribute to solving it. For example, we might choose to put each session in its own SQL lite database.

@wwqrd
Copy link
Contributor

wwqrd commented Oct 28, 2020

I did some investigation on this, and I'm not sure a persist plugin is what we need if the store is getting too large.

What might work well is some custom redux middleware which sideloads the sqlite data as and when it's needed - something like the following perhaps?:

const sessionsStore = store => next => action => {
  switch (action.type) {
    case 'persist/REHYDRATE':
      // inject session from sqlite if an active sessionId
    case 'SET_SESSION':
      // load session from store
    case 'END_SESSION':
      // save session to db
    default:
      return next(action);
  }
};

@jthrilly jthrilly self-assigned this Nov 9, 2020
@jthrilly jthrilly mentioned this issue Nov 9, 2020
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants