enable kvstore to bulk remove key/value pairs
Categories
(Toolkit :: Storage, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: myk, Assigned: nanj)
Details
Attachments
(1 file)
Bug 1522638 added bulk insert/clear to kvstore, which satisfies a number of use cases for transactions (bug 1499238), but there's one significant remaining case: a bulk change that removes multiple key/value pairs but doesn't clear them all.
With that addition, the "bulk change" feature set of kvstore should be sufficient to avoid the need for transactions and close bug 1499238 as wontfix.
One approach would be to add an nsIKeyValueDatabase.deleteMany()
method that removes multiple pairs, which would satisfy the use case when pairs are only being removed.
But if pairs are also being inserted, and the consumer wants transactional semantics (either all pairs are inserted/removed or none of them are), then it'd be better to support both insertion and removal in the same single method call.
We could do that in nsIKeyValueDatabase.putMany()
by allowing consumers to specify removal of a pair via an nsIKeyValuePair
whose value
is a void/empty variant.
Then nsIKeyValueDatabase.putMany({ "foo": "bar", "baz": null })
would insert the "foo": "bar" pair while removing a pair whose key is "baz" (if any).
Assignee | ||
Comment 1•5 years ago
•
|
||
Multiplexing deletion on putMany
sounds a bit confusing to me, the consumer could also delete items inadvertently. FWIW, the current implementation treats 'null' as the invalid value thus will not finish the bulk insert.
Wonder if we can add a new API, say writeMany()
, that can handle both put and delete with the argument proposed above.
We could still provide consumers with putMany
and deleteMany
on top of it for the better ergonomics.
Assignee | ||
Updated•5 years ago
|
Reporter | ||
Comment 2•5 years ago
|
||
(In reply to Nan Jiang [:nanj] from comment #1)
Wonder if we can add a new API, say
writeMany()
, that can handle both put and delete with the argument proposed above.We could still provide consumers with
putMany
anddeleteMany
on top of it for the better ergonomics.
That seems reasonable to me.
Assignee | ||
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Comment 3•5 years ago
|
||
This new API allows consumer to both put and delete in batch.
Pushed by najiang@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/693db1b99225 Add writeMany to kvstore r=myk
Comment 5•5 years ago
|
||
bugherder |
Description
•