BYOJS / storage

Simple key-value storage API backed by various client storage mechanisms
https://byojs.dev/storage/
MIT License
87 stars 2 forks source link

investigate "storage buckets" #1

Closed getify closed 1 month ago

getify commented 2 months ago

https://developer.chrome.com/docs/web-platform/storage-buckets

MatheusBonavite commented 1 month ago

Hello @getify, I might be stating the obvious here so pardon me if this is the case.

However, it seems like Storage Buckets operate on top of an already established storage API, like indexedDB: which you are already using through the "idb-keyval" package! Notice that somebody has already pushed this conversation there: https://github.com/jakearchibald/idb-keyval/issues/174

If they work on that I believe you could do some testing for free, or almost for free, in this amazing project with Storage Buckets. Or, you could clone that dependency and do the suggestion in the opened issue and then use the set/get APIs with the small change of using StorageBucket.indexedDB instead of window.indexedDB.

Dropped this two cents here just to see if it helps! Regards

getify commented 1 month ago

TBH I only found the article about them, haven't read it yet, don't know what they're for or if they're relevant at all here. this is mostly a research task, not yet a dev task. :)

Suyog1702 commented 1 month ago

Here’s a concise summary of the Storage Buckets API:

Multiple Storage Buckets: Developers can create separate buckets to prioritize which data to keep or discard under storage pressure

Granular Control: Allows for fine-grained control over persistent storage, avoiding the traditional "all-or-nothing" approach for data persistence​

Eviction Prioritization: Developers can assign priorities to buckets, ensuring important data (e.g., unsent drafts) remains while less critical data can be evicted​

Customizable Durability: Buckets can have different durability settings—strict for safer but slower writes, or relaxed for faster, more performance-optimized writes

API Compatibility: Works with common web storage APIs like IndexedDB, Cache API, and File API​

DevTools Integration: Storage buckets can be debugged and monitored via Chrome DevTools

Hope this helps :)​

getify commented 1 month ago

Thanks for the info. After thinking about it, I don't think this makes sense for this library, at this time. If it expands beyond a Chrome-only feature, it may be worth re-visiting.