Storage: Difference between revisions
Jump to navigation
Jump to search
m (lmdb landing bug linkage) |
m (fix rust binding thought and improve link.) |
||
Line 2: | Line 2: | ||
Possibilities include: | Possibilities include: | ||
* mozStorage, the API that lives under [https://searchfox.org/mozilla-central/source/storage storage/] in the source tree. This is a C++ wrapper around SQLite that is also exposed to JS via both XPCOM/XPConnect ([https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Storage API docs]) and via a friendlier JS wrapper, [https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Sqlite.jsm SQLite.jsm]. Bug 1482608 also | * mozStorage, the API that lives under [https://searchfox.org/mozilla-central/source/storage storage/] in the source tree. This is a C++ wrapper around SQLite that is also exposed to JS via both XPCOM/XPConnect ([https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Storage API docs]) and via a friendlier JS wrapper, [https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Sqlite.jsm SQLite.jsm]. [https://bugzilla.mozilla.org/show_bug.cgi?id=1482608 Bug 1482608] also has prototype rust bindings that may eventually land. | ||
* The profile "storage/" directory that holds per-origin storage managed by the QuotaManager subsystem and its clients: IndexedDB, the Cache API, and the asm.js cache (which will be removed). | * The profile "storage/" directory that holds per-origin storage managed by the QuotaManager subsystem and its clients: IndexedDB, the Cache API, and the asm.js cache (which will be removed). | ||
Revision as of 16:17, 13 September 2018
Storage can mean many things in Gecko and Firefox.
Possibilities include:
- mozStorage, the API that lives under storage/ in the source tree. This is a C++ wrapper around SQLite that is also exposed to JS via both XPCOM/XPConnect (API docs) and via a friendlier JS wrapper, SQLite.jsm. Bug 1482608 also has prototype rust bindings that may eventually land.
- The profile "storage/" directory that holds per-origin storage managed by the QuotaManager subsystem and its clients: IndexedDB, the Cache API, and the asm.js cache (which will be removed).
Storage Alternatives
There are many options for storing data in Gecko. The Browser Architecture Group has cataloged many of the existing uses.
If you are looking for a way to store data in Firefox, here are the usual options:
- JSON flat files. This usually is not a viable option from C++ because we don't have convenient ways to manipulate JS objects from C++.
- rkv, a "simple, humane, typed Rust interface to LMDB" available in Gecko since Firefox 63. LMDB is a memory-mapped flat file database.
- SQLite via the mozStorage API or bindings. You should *NOT* directly access the SQLite API. If you are using rust code and would like a better binding API than mozStorage, that makes sense, but please reach out to the Storage Advisory Group so that we can reach consensus. We do not want to have N separate bindings to SQLite, especially since mozStorage is responsible for global configuration settings that could fight with other SQLite bindings.