garbados / comdb

A PouchDB plugin that transparently encrypts and decrypts its data.
61 stars 4 forks source link

chore: add queue to loadDecrypted #29

Closed garbados closed 2 years ago

garbados commented 2 years ago

This PR uses a queue to make loading decrypted docs into an encrypted copy faster and more efficient. Previously, each decrypted doc would be loaded into the encrypted copy one-by-one. This is very slow. Instead, we load docs into an in-memory queue from which we load documents into the database in bulk. The queue's harvest limit is 100. That is, whenever the queue exceeds 100 documents, those documents are loaded into the database and the queue is reset. At the end of loadDecrypted() any remaining docs are also loaded en masse.