Open samuelcarreira opened 6 years ago
Totally agree. I was very surprised when I looked at the code and saw that all work with the file system is synchronous.
I think it would be much better to make a copy of the data in a global variable. And when you change this data, it is invisible, asynchronously, to synchronize it with a local file, if needed.
Yeah, you are right, @sindresorhus any word?
I am currently working on a alternative library to save the settings. Main highlights:
I will post here when I publish the process
@samuelcarreira waiting for this
@sayem314 I am happy to announce that you can try the beta version of my module https://github.com/samuelcarreira/electron-json-settings-store I need all the feedback that you can provide
@sayem314 I am happy to announce that you can try the beta version of my module https://github.com/samuelcarreira/electron-json-settings-store I need all the feedback that you can provide
Is it for electron only? I don't use electron.
Also Sindre Sorhus himself recommends his other module electron-store for electron
@sayem314 It's only for electron
@papb the electron-store is basically a wrapper of the conf module, so the complaints are the same
I just want to make everyone aware that this exists and does more or less what is required https://github.com/SamVerschueren/cache-conf It is however seriously outdated, so giving it a refresh may be a better course of work, rather than starting from scratch.
I am also wondering if this is an issue altogether, since modern operating systems usually have their own RAM cache for frequently used files. This is transparent for tools like node, but my guess is that file accessed multiple times a second will be cached, unless you are running very low on RAM.
I dug up a little inside the conf module code and appears to me that each get/read function call uses the
fs readFileSync
to get the data from the config file. If I need to constantly check for a value from the app settings it can lead to performance issues. So my approach is to copy the settings to a global variable 👎 and only use this module to write the config file when some changes occur.Are any alternative approach to this problem or do you plan to add a feature to kinda "cache the values" and only reads the file when there are some changes?
Thank you