behrad / mqtt-nedb-store

NeDB store for in-flight MQTT.js packets.
MIT License
9 stars 4 forks source link

feature: add autocompactionInterval #3

Closed tkurki closed 5 years ago

tkurki commented 5 years ago

Add autocompactionInterval options properties to incoming and outgoing stores.

Fixes #2.

Tested manually, as the mocha tests are broken in master.

tkurki commented 5 years ago

Any comments on this?

behrad commented 5 years ago

thank you @tkurki

tkurki commented 5 years ago

No problem! Please remember to publish to npm as well, isn’t there yet afai can see.

tkurki commented 5 years ago

Pretty please? Not very motivating to contribute upstream if the result is never published, forking would be less effort for me but worse overall.

behrad commented 5 years ago

Done!

mugul commented 5 years ago

Hi there!

Does the autoCompactionInterval helps me to reduce the size of the file and clean the deleted rows? I got an error with a "toString()" while trying to restart the process because the file was way too big... The software i'm using should be alive for months without restart.

And the second question, and most important... it's value should be in milliseconds or seconds?... I think it should be milliseconds but that "60" in the readme got me a little confused.

Thanks for your support and sorry if this is not the way to ask.

tkurki commented 5 years ago

Value is in milliseconds.

Yes this will reduce the file size and get rid of the deleted rows, but be aware that nedb will still load the whole database into memory. If you lose mqtt server connectivity so that the outgoing queue size gets huge (lots of large messages) you may be again in trouble. Guess how I know...switched to mqtt-level-store for my use case.

mugul commented 5 years ago

Thank you very much for your reply and advice.

Have a nice day!