We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Is it possible to define multiple drivers with fallback logic?
For example use IndexDB if supported, else fallback to use LocalStorage.
This is something that LocalForage supports, which is great to have this "use best option" functionality.
localForage.config({ driver: [ this.unstorage.INDEXEDDB, this.unstorage.WEBSQL, this.unstorage.LOCALSTORAGE ] });
Is this currently possible with unstorage? If not could this be implemented with a custom driver?
unstorage
The text was updated successfully, but these errors were encountered:
One idea is a simple try-catch, try using indexedDbDriver, if it fails then fallback to localStorageDriver.
try-catch
indexedDbDriver
localStorageDriver
try { this.unstorage = createStorage({ driver: indexedDbDriver({ storeName: "app" }) }); } catch (error) { this.unstorage = createStorage({ driver: localStorageDriver() }); }
Will this work? Is there a better option?
Sorry, something went wrong.
I suggest implementing a few common policies like read-through/write-through etc. see: https://www.prisma.io/dataguide/managing-databases/introduction-database-caching I've recently implemented a TieredStorage driver in my own project, it's under tests and I'll create a PR when it's ready.
TieredStorage
No branches or pull requests
Describe the feature
Is it possible to define multiple drivers with fallback logic?
For example use IndexDB if supported, else fallback to use LocalStorage.
This is something that LocalForage supports, which is great to have this "use best option" functionality.
Is this currently possible with
unstorage
? If not could this be implemented with a custom driver?Additional information
The text was updated successfully, but these errors were encountered: