Storage

From MozillaWiki
Revision as of 15:55, 13 September 2018 by Andrew Sutherland (talk | contribs) (Update the page per discussion with storage advisory group)
Jump to navigation Jump to search

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
  • 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". 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.