Synchronization between local/memory storage and external/file/db storage
Rednas83 opened this issue · 0 comments
Rednas83 commented
Describe the feature
Would be cool if support could be added for an optional synchronization mechanism to support offline usage of external storage.
Something like
const user = await useStorage().login('user1') // local authentication
try {
const dataStorage = useStorage('data').setItem('test', 'works') // set item online if possible otherwise use the local storage as a fallback
}
catch (e) {
const popup = await popup(`Solve conflict for (${e.description})`, e.newValue, e.differentValue) // Provide mechanism for solving conflicts when the connection is restored
}
await useStorage().getItem('data:test') // Can be accesed from memory when the storage is already in sync with the external storage
await user.logoff()
Advantages
- Work offline without server connection
- Solve conflicts when the server connection is restored by returning errors with the values that are not matching
- More app performance because local storage is used
Disadvantages
- Requires timestamping and support for users I guess to support solving conflicts
- Slower storage on the server
- Less secure?
Additional information
- Would you be willing to help implement this feature?