gundb / feature-requests

What extra features do you want for gun? Discuss here!
10 stars 0 forks source link

Write to disk delay with write ahead log #30

Open Defragmented-Panda opened 6 years ago

Defragmented-Panda commented 6 years ago

For usage with sd cards its better to write less often and in bigger chunks to ensure that sdcard doesnt die quickly.

Is there any way to separate .put() from actual disk write? Ideally gundb might have 2 parts, a log of few last actions kept in ram, and bigger file kept in storage, that is updated with a log once every minute or so.

When gundb needs to send data by network or show it to user, it should first check the log, and if it has nothing related, then check the disk storage. This way both storages are seen as one for a user, hopefully.

Also this might help to make gundb fully in memory or fully on disk type of db, if users would have a control how often a disk write is done

amark commented 6 years ago

@Defragmented-Panda great comments! This is actually already implemented as the Radix Storage Engine (RSE) and the in-memory portions as GUN core.

There isn't much documentation on RSE at the moment :/ :( we need to get that fixed, basically just: https://gun.eco/docs/Storage#radix .

Happy to answer any questions here. Let me know! Else, I'll close this issue in a few. Cheers!

Defragmented-Panda commented 6 years ago

I cant seems to find anything related to radix storage engine or rse

I get it that Gun({localStorage: false}) should help turn the radix on, but i dont know what does it do

I did check https://github.com/gundb?tab=repositories it has sqlite and leveldb storages(do they have the write delay?), but not radix. where can i find radix source? That might work as a documentation too (so i can use it)

Thanks for a quick response!

amark commented 6 years ago

@Defragmented-Panda yeah :) welcome to the community :) please do come join the https://gitter.im/amark/gun (bunch of friendly fast-replying people there) and tell us about your project/what you are building / how you heard about us!

Source code for the "radix on disk" (radisk) is here: https://github.com/amark/gun/blob/master/lib/radisk.js

Source code for the adapter that connects gun to the radisk and provides a default interface (others include S3, etc.) https://github.com/amark/gun/blob/master/lib/store.js

Source code for the actual radix tree implementation (not easy to understand) https://github.com/amark/gun/blob/master/lib/radix.js

I hope that helps! And please hit up the chat room for better help. :)